Am 25.07.2012 07:17, schrieb Amos:
 >>> [obj.code for obj in
Session.query(Model).filter_by(my_column=123).all()]

[u'123ad', u'123lpb', u'123xd8', u'123za0']

I would expect no results as no column exactly matches the string
representation of my number

Your result will depend on how your database engine compares strings to integers. I can imagine that on some databases you will get no results, on some you get an Error, because they refuse to make automatic type conversions, and on some you will get what you got because they convert the string '123ad' to the integer 123 (this is how e.g. the C function atoi works). I haven't tested it, but I can imagine that Postgres will throw an error and MySQL will give your result. That's one of the many reasons I prefer Postgres.

-- Christoph


--
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to