-
Notifications
You must be signed in to change notification settings - Fork 45
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
POC - Add custom database role #455
base: main
Are you sure you want to change the base?
Conversation
|
||
attribute = @columns.first.split(".").second.to_sym | ||
|
||
relation = relation.where(model.arel_table[attribute].gt(@position.first)) |
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.
This change is to demonstrate that using arel_table
does not treat the id column as strings in the generated SQL:
# original SQL:
Stripe::Fee.where("id > ?", 3).to_sql
=> "SELECT `stripe_fees`.* FROM `stripe_fees` WHERE (id > '3')"
# SQL with arel_table:
Stripe::Fee.where(Stripe::Fee.arel_table[:id].gt(3)).to_sql
=> "SELECT `stripe_fees`.* FROM `stripe_fees` WHERE `stripe_fees`.`id` > 3"
MySql is lenient and allows such comparison, however BigQuery raises an exception for this behaviour:
Google::Cloud::InvalidArgumentError: No matching signature for operator > for argument types: INT64, STRING.
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.
Yeah we had noticed that too, making use of arel_table
does the trick, however it becomes very cumbersome to convert database table names into constantized classes in the jobiteration
layer.
I just had a pairing session with @bony2023 and we managed to patch the bigquery adapter to prevent the coercion.
All details in this PR: https://github.com/Shopify/activerecord-bigquery-adapter/pull/4
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.
That being said we may want to revisit that coercion on the Mysql queries too 👍
as you pointed out even though it is lenient about it ain't ideal.
1198efe
to
ad7d29a
Compare
@@ -18,23 +18,16 @@ def initialize | |||
end | |||
end | |||
|
|||
def initialize(relation, columns = nil, position = nil) |
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.
…rings