wice_grid icon indicating copy to clipboard operation
wice_grid copied to clipboard

Postgres column name with "-" not correctly handled

Open afdev82 opened this issue 3 years ago • 0 comments

Environment

  • Ruby 3.0.3p157
  • Rails 6.1.5
  • WiceGrid 4.1.0 3ae1bec

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:

SELECT DISTINCT "configurations"."configuration_id" AS alias_0, "configurations"."configurations"."configuration_id" FROM "configurations"."configurations" LEFT OUTER JOIN "alchemy_sites" ON "alchemy_sites"."id" = "configurations"."configurations"."website_id" LEFT OUTER JOIN "system"."countries" ON "system"."countries"."country_id" = "configurations"."configurations"."country_id" LEFT OUTER JOIN "configurations"."custom_models" ON "configurations"."custom_models"."custom_model_id" = "configurations"."configurations"."custom_model_id" LEFT OUTER JOIN "system"."users" ON "system"."users"."user_id" = "configurations"."configurations"."user_id" LEFT OUTER JOIN "configurations"."prices" ON "configurations"."prices"."configuration_id" = "configurations"."configurations"."configuration_id" WHERE (("configurations"."configurations"."is_preset" = TRUE AND "configurations"."configurations"."measurement_system" = 'metric' AND "configurations"."configurations"."deleted_at" IS NULL) OR (("configurations"."configurations"."website_id" IN (7, 12, 10, 5, 8, 2, 9, 11, 3, 1, 4, 6) AND "configurations"."configurations"."deleted_at" IS NULL) OR (("configurations"."configurations"."user_id" = 1 AND "configurations"."configurations"."website_id" = 1 AND "configurations"."configurations"."deleted_at" IS NULL) OR ("configurations"."configurations"."user_id" = 1 AND "configurations"."configurations"."website_id" = 1 AND "configurations"."configurations"."deleted_at" IS NULL)))) AND "configurations"."configurations"."archived_at" IS NULL AND ( configurations.configurations.glass_mounting_type = 'rm_gm') AND ( configurations.configurations.display_mounting_type = 'mws') AND "configurations"."configurations"."configurable" = $1 AND ( configurations.configurations.display-id = '738') ORDER BY "configurations"."configuration_id" DESC LIMIT $2 OFFSET $3  [["configurable", true], ["LIMIT", 20], ["OFFSET", 0]]

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:

PG::UndefinedColumn: ERRORE:  la colonna configurations.display non esiste
LINE 1: ...tions"."configurations"."configurable" = $1 AND ( configurat...
                                                             ^
HINT:  Forse intendevi referenziare la colonna "configurations.display-id".

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!

afdev82 avatar Apr 12 '22 17:04 afdev82