-
Notifications
You must be signed in to change notification settings - Fork 3
Column order issue on select statement - task - https://app.clickup.c… #17
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
base: master
Are you sure you want to change the base?
Conversation
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.
cc: @NileshN @satishaher
query = build_query() | ||
@results = @model.find_by_sql([query, @bind_variables]) # Execute Sql Query | ||
query = to_sql | ||
@results = @model.connection.select_all(query).as_json # Execute Sql Query |
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.
@Girish2402 Do you have any test result to prove that it is not changing output, In my understanding select_all
returns array of hash or json and find_by_sql
returns model objects.
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.
@Girish2402 Can you also explain why do you need this change? what is the use case?
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.
@vishalzambre
We rely on the order that we pass on the select statements in query for CSV column order but it's not getting the same order.
Task - https://app.clickup.com/t/1c5cry4
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 add test cases for association(include) but its fails.
Association is failing for these changes.
https://github.com/patterninc/query_helper#associations
Do not merge changes.
Test results:
Failure/Error: ActiveRecord::Associations::Preloader.new.preload(payload, associations)
NoMethodError:
undefined method `_reflect_on_association' for Hash:Class
Description
find_by_sql doesn't preserve the column order.
reference link - https://stackoverflow.com/questions/209558/column-order-of-results-from-rails-activerecord-find-by-sql-call
Clickup Story
https://app.clickup.com/t/1c5cry4
Deployment Details
Standard process
Reminders