sqlalchemy ArgumentError: Textual SQL

Viewed 2149

ArgumentError raises when passing plain text to "order_by". I'ts occurs with version 0.9.8, but not with version < 0.9.8 or > 0.9.8.

q = session.query(Person)
q.order_by('RAND()')
>> ArgumentError: Textual SQL expression 'RAND()' should be explicitly declared as text('RAND()')

questions: 1. Is there any official documentation about it? 2. With new versions, is this a good practice to pass plain text, or it is better to wrap it with text()? 3. Is this error raises with more functions other then order_by?

0 Answers
Related