forked from leikind/wice_grid
-
Notifications
You must be signed in to change notification settings - Fork 28
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
Postgres column name with "-" not correctly handled #82
Comments
afdev82
changed the title
Postgres column name with "-" not handled correctly
Postgres column name with "-" not correctly handled
Apr 12, 2022
Closed
afdev82
added a commit
to adnotam/wice_grid
that referenced
this issue
Oct 24, 2024
afdev82
pushed a commit
to adnotam/wice_grid
that referenced
this issue
Oct 24, 2024
Only call group when there actually is a group set in WiceGrid#read relation This fixes a bug with wrong paginated result set when having a wice_grid with an include or column with assoc option on a many association. If this is the case the grid tries to eager load this association (due to the include/references on the relation). Rails then normally gets the correct page set by performing an additonal query to get the matching IDs without the eager load, however this functionality is disabled when there is a group set on the relation. Because WiceGrid always called group even when there was no group set this behaviour was always disabled, leading to an incorrect page set. By only calling group when there actually is a group we fix this problem in most cases. However, when providing a group to the grid, problems still occur, but so does providing a group to a relation with eager load in PostgreSQL in Rails itself already (e.g. `Author.eager_load(:books).group(:id)`). It might be better to never eager load associations, but instead always preload them and add the sort/filter conditions using a left_joins (in combination with a distinct to get each main model only once). Also return Arel in get_custom_order_reference when custom order is SqlLiteral Fixes 'Query method called with non-attribute argument(s)' when using Arel.sql for custom order in combination with Ruby 3. Should already have been fixed when the deprecation warning was fixed, but apparently it was not. Fixup c7a9da2 fix for issue patricklindsay#82
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Environment
Description of issue
I found that if the column name contains a "-" in it, I get an error when I filter the table.
In fact I saw from the stack trace and the SQL log what's happening:
The column name in the query is
configurations.configurations.display-id
and not"configurations"."configurations"."display-id"
.If I copy the query in PgAdmin and I execute it with the quotes applied, it's fine.
I think it should be changed the way the column name is generated by
wice_grid
to handle this case.I digged into the code, but not enough yet to have a solution.
Current behaviour
I get an error:
That means the column "configurations.display" and maybe I wanted to reference the "configurations.display-id".
Expected behaviour
I get the filtered results page.
Thank you for your support!
The text was updated successfully, but these errors were encountered: