3 0 stable #172

wants to merge 9 commits into


None yet

2 participants


This is fix of the problem in this discussion: http://groups.google.com/group/rails-sqlserver-adapter/browse_thread/thread/e04613db0882f491

I had to do something different than in #155

That discussion fixes the problem that an sql-query might have a , (comma) in it. My problem was that an sql query might be longer than "expression direction". The code as it was took only the first word of expression and made the second word the direction, even though something like this: "CASE WHEN ended_on IS NULL THEN 1 ELSE 0 END DESC" is valid sql, where the expression is the entire sentence, and the direction is nil.

I think this problem still remains in the branches for 3.1. and 3.2.

  • Niels
metaskills and others added some commits Sep 16, 2011
@metaskills metaskills New testing setup for 3-0-stable. b794be9
@metaskills metaskills Allow complex order objects to not be molested by our visitor overrid…
…es. Fixes #99
@metaskills metaskills 3-0-stable is now 3.0.16. acc8c63
@metaskills metaskills 3-0-stable is now future 3.0.17. 80e6363
@metaskills metaskills Fix test_count_explicit_columns. 31e5e53
@metaskills metaskills Allow :limit/:offset to be used with fully qualified table and column…
… in :select.
@metaskills metaskills Make #rollback_db_transaction smarter. 2e45783
@metaskills metaskills Misc changes.
* Create a #configure_connection method that can be overridden. Think "SET TEXTSIZE...".
* Create a #configure_application_name method that can be overridden for unique TinyTDS app names
  to show up in SQL Server's activity monitor.
* Fixed the #finish_statement_handle to cancel the TinyTDS connection if needed.
* Fix the #indexes method to fail gracefully if sp_helptext permissions fail.
@nielsjansendk nielsjansendk trying to split input corretly into expression and direction 4d496e6

Why are the commits so big in this pull request? Like you have commits to the change log that are already in 3-0-stable? Did something go wrong in the pull request?


Yeah, seems like something went wrong, I just did this nielsjansendk@4d496e6... must not have committed it right... I checked out out branch 3-0-stable and committed to that one. Are your commits not in 3-0-stable?


@nielsjansendk You made the pull request from 3-0-stable to master. I was just reviewing some commits to do some updated and noticed this. Can you show me a failing test that this fixes? If so, I'll look at getting this in all upcoming branches.


Try sticking an order like this in a chain and watch it blow up:

:order => 'CASE WHEN ended_on IS NULL THEN 1 ELSE 0 END DESC, ended_on DESC'

I want to sort in descending order, except those who has ended_on nil should come first, not last.


Closing this. Complex orders need to be constructed in such a way so that ActiveRecord does not munge them, as this test shows.

should 'not mangel complex order clauses' do
  xyz_order = "CASE WHEN [title] LIKE N'XYZ%' THEN 0 ELSE 1 END"
  xyz_post = Post.create :title => 'XYZ Post', :body => 'Test cased orders.'
  assert_equal xyz_post, Post.order(Arel::Nodes::Ordering.new(Arel.sql(xyz_order))).first
@metaskills metaskills closed this Aug 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment