-
Notifications
You must be signed in to change notification settings - Fork 800
ZF-1.12.7 breaks code when using multi column ordering #378
Comments
@ezimuel Can you please work with @DragonBe on this? Also, @DragonBe - I can see a number of ways to accomplish what you want with existing functionality that would work in both 1.12.6 and 1.12.7: $select->order(array('productId', 'ASC')); // SELECT ... ORDER BY 'productId' ASC
$select->order(new Zend_Db_Expr("'productId' ASC")); // same
$select->order(array(
new Zend_Db_Expr("'productId' ASC"),
new Zend_Db_Expr("'userId' DESC"),
)); // SELECT ... ORDER BY 'productId' ASC, 'userId' DESC I'm a bit surprised, though, that the string |
@DragonBe I'm very surprised that the unit tests didn't cover this simple use case, all the tests was green. Anyway, I'll work on this to discover what is happened, adding more tests of course. |
I'm almost done with my unit tests, will send a pull request in the next 20 minutes. Well, now we're going to have them in for future changes as well. |
@weierophinney I'd love to make those changes to my code, but we're having over a 1000 queries like this… fixing the ZF1 code seems like a more proper way of doing it. |
@DragonBe Thanks for the unit tests! I'm checking and I'll let you know asap. |
👍 |
@DragonBe I tested your SQL statements and all passed! Can you execute this example code on your environment and let me know? Thanks! |
I'm confused now! @ezimuel, I ran your test on several of our servers and all passed! Even ran the script in isolation with version output, still all passed. I also completed my test case scenarios for the whole issue and committed it to GitHub, ran all the tests with both Mysqli and Pdo_Mysql. They all pass except one use case: multi fields for ordering, one without and one with direction! See my ZF-378 test cases yourself and run them independently to validate the issue. |
Hmm, fixed a typo pointed out by @weierophinney and updated an expectation to a real value, and I can no longer recreate the issue: all tests pass! Need to figure this one out once I'm back in the office next week… I must be missing something. Anyways, I will create these testcases for ZF1 so at least every future change can be tested against it. |
Maybe related: |
Last night we upgraded our codebases with the latest ZF1 version 1.12.7 which triggered all sorts of alarm bells. It took us about half a day to figure out why this was.
We have queries using multi-column ordering, which are now no longer functional because of the security fix ZF2014-04, as it was mentioned in the release notes:
Example Zend_Db_Select statements that fail now:
This code now translates into the following query
Which triggers the following MySQL errors:
Mysqli prepare error: Unknown column 'productId ASC'
Mysqli prepare error: Unknown column 'productId ASC, userId DESC'
I can imagine this is not the required result this fix should be!
We can't upgrade at this point.
The text was updated successfully, but these errors were encountered: