New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make sure order quote symbol arguments #12718
Conversation
@@ -35,15 +35,7 @@ def relation | |||
assert relation.order!('name ASC').equal?(relation) | |||
assert_equal ['name ASC'], relation.order_values | |||
end | |||
|
|||
test '#order! with symbol prepends the table name' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the test was removed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because they were very specific to implementation.
After we remove preprocessing, order_values
will contain raw data, so there are no ascending?
, expr.name
and expr.relation.name
.
I tried swap node = relation.order_values.first
with node = relation.arel.orders.first
, but it raises error.
So i decided remove those specs for now.
Please let me know if i need bring them back and adapt to current implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can also add specs here to cover hash arguments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Yes, we will need some integration tests to make sure the behavior was ne regressed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I will work on tests.
@rafaelfranca i added tests |
@Timsly is this PR still required? I tried to reproduce the error case with def test_order_by_key
Post.create(key: "b")
Post.create(key: "c")
Post.create(key: "a")
assert_equal ["a", "b", "c"], Post.order(:key).to_a.map(&:key)
end I create a gist of the complete example. @Timsly Let me know if I'm missing something or if we can close this PR. |
It's been a month without feedback. I'm going to close this PR. If the requested change is still necessary please report back so we can reopen. |
Current order implementation contains symbol parsing and converting it to
Arel::Nodes::Ordering
But this code will be never executed, because we preprocess symbol params and convert it to
Arel::Nodes::Ascending
.But when we convert it to
Arel::Nodes::Ascending
it has issues with some values(for example:key
, see here #2601)So i removed symbol preprocessing and leave all calculation on
build_order
methodAlso this pull fixes
limited_ids_for
method for postgresql adapter, which is passingorder_values
(raw values that we pass to order) tocolumns_for_distinct
. So for symbol(after i removed preprocessing) and hash arguments it will raiseNoMethodError
, because there is noto_sql
method