On 4/20/15 8:09 AM, Guido Winkelmann wrote:
Hi,

Have there been any non-backwards-compatible changes in SQLAlchemy 1.0 compared to 0.9.9?

We are seeing a lot of sudden breakage in our unit tests when switching to SQLAlchemy 1.0 from 0.9.9. Tests that worked fine before suddenly fail across the board.

Here's a an example of a test build that suddenly failed on 1.0:

https://travis-ci.org/pyfarm/pyfarm-master/builds/58860924

If you compare the builds on sqlite with those MySQL/PostgreSQL, you will see there are two different, seemingly unrelated things going wrong:

On sqlite, drop_all() seems to fail to get the order of table drops right, and consequently runs into a referential integrity error.

On MySQL/PostgreSQL, this line fails:

association = TaskTaskLogAssociation.query.filter_by(task=task, log=task_log, attempt=attempt).first()

In this context, "log" is a relationship in the model TaskTaskLogAssociation to model TaskLog. "task_log" is an object of type TaskLog, but one that has never been written to the database and has no set id. That leads to this error message in the logs:

nose.proxy.ProgrammingError: (psycopg2.ProgrammingError) function symbol(unknown) does not exist
LINE 3: ...72015052936_task_log_associations.attempt = 1 AND symbol('NE...
   ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts. [SQL: 'SELECT test29172015052936_task_log_associations.task_log_id AS test29172015052936_task_log_associations_task_log_id, test29172015052936_task_log_associations.task_id AS test29172015052936_task_log_associations_task_id, test29172015052936_task_log_associations.attempt AS test29172015052936_task_log_associations_attempt, test29172015052936_task_log_associations.state AS test29172015052936_task_log_associations_state \nFROM test29172015052936_task_log_associations \nWHERE test29172015052936_task_log_associations.attempt = %(attempt_1)s AND %(param_1)s = test29172015052936_task_log_associations.task_log_id AND %(param_2)s = test29172015052936_task_log_associations.task_id \n LIMIT %(param_3)s'] [parameters: {'param_1': symbol('NEVER_SET'), 'attempt_1': 1, 'param_2': 1, 'param_3': 1}]

Apparently, sqlalchemy will use "symbol('NEVER_SET')" where the id of the model used for filtering should be.

It may be a bit questionable to filter by a model that doesn't even exist in the database, but, again, this used to work fine in 0.9.9.

This is odd. What was "working fine" in 0.9.9 doing exactly? Was it coming out with "NULL = test29172015052936_task_log_associations.task_log_id" ? Looking in 0.9, there is no logic in this case to convert the "=" to "IS" in this case as the parameter from the object is not evaluated til after the query is generated. This query will *always* return False, because NULL cannot be compared with "=".

I guess that's whats desired here, that the query returns nothing, but this is a lot like the idea of "x IN ()", e.g. it's useless to emit this query, and it relies upon kind of a weird quirk of SQL. I almost wonder if this should emit a warning. Because if we do eventually make it so that IS NULL comes out, the results can change for more complex relationships that explicitly want to compare some columns to NULL.











Regards,
  Guido W.
--
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 <mailto:sqlalchemy+unsubscr...@googlegroups.com>. To post to this group, send email to sqlalchemy@googlegroups.com <mailto:sqlalchemy@googlegroups.com>.
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

--
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 http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to