Hi,

I tried using direct  plain JSON:

my model
class Student(db.Model):
__tablename__        = 'students'
id=db.Column(db.Integer, primary_key=True,autoincrement=True)
name=db.Column(db.String(200))
roll_no=db.Column(db.Integer)
data_test=db.Column(db.JSON)


I tried this:
*a = Student.query.filter(cast(Student.__table__.c.data_test["foo"], 
String) =="bar").**first**()*

*error*:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) operator does 
not exist: json -> unknown
LINE 3: WHERE CAST((students.data_test -> 'foo') AS VARCHAR) = 'bar'
                                       ^
HINT:  No operator matches the given name and argument type(s). You might 
need to add explicit type casts.
 [SQL: 'SELECT students.id AS students_id, students.name AS students_name, 
students.roll_no AS students_roll_no, students.data_test AS 
students_data_test \nFROM students \nWHERE CAST((students.data_test -> 
%(data_test_1)s) AS VARCHAR) = %(param_1)s'] [parameters: {'param_1': 
'bar', 'data_test_1': 'foo'}]


tried this:
*a = Student.query.filter(Student.data_test.op('->>')('foo') == 
'bar').first()*

*error*:
sqlalchemy.exc.ProgrammingError: (psycopg2.ProgrammingError) operator does 
not exist: json ->> unknown
LINE 3: WHERE (students.data_test ->> 'foo') = 'bar' 
                                  ^
HINT:  No operator matches the given name and argument type(s). You might 
need to add explicit type casts.
 [SQL: 'SELECT students.id AS students_id, students.name AS students_name, 
students.roll_no AS students_roll_no, students.data_test AS 
students_data_test \nFROM students \nWHERE (students.data_test ->> 
%(data_test_1)s) = %(param_1)s \n LIMIT %(param_2)s'] [parameters: 
{'param_1': 'bar', 'data_test_1': 'foo', 'param_2': 1}]



is this some versioning issue?
I am not able to understand, where am i going wrong?

Thanks for any help in this

-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to