You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What would you like to be able to do? Can you provide some examples?
I have table GroupItems and table Groups. Groups has a jsonb column type called lms_data. I want to search on the field name inside lms_data. I am using the gem administrate that helps you created dashboard with search functionality. In your dashboard you can declare a field with a search configuration :
then on search the gem will build the query dynamically, here it builds : "SELECT \"group_items\".* FROM \"group_items\" LEFT OUTER JOIN \"groups\" ON \"groups\".\"account_id\" = 4 AND \"groups\".\"id\" = \"group_items\".\"group_id\" WHERE \"group_items\".\"account_id\" = 4 AND (LOWER(CAST(\"groups\".\"lms_data->>'name'\" AS CHAR(256))) LIKE '%adv%')"
However this throws an error :
PG::UndefinedColumn: ERROR: column groups.lms_data->>'name' does not exist
LINE 1: ...E "group_items"."account_id" = $2 AND (LOWER(CAST("groups"."..
What is the correct syntax to query lms_data->>'name' within joined groups table ?
Two solutions come to mind. The first one would be changing Administrate so that, somehow, we can pass field names that shouldn't be quoted at that point. Perhaps we could create a class that is a bit like Rails's own ActiveSupport::SafeBuffer, which is just a string flagged so that it is skipped by the ERB escaping. Like this:
I have table GroupItems and table Groups. Groups has a jsonb column type called lms_data. I want to search on the field name inside lms_data. I am using the gem administrate that helps you created dashboard with search functionality. In your dashboard you can declare a field with a search configuration :
then on search the gem will build the query dynamically, here it builds :
"SELECT \"group_items\".* FROM \"group_items\" LEFT OUTER JOIN \"groups\" ON \"groups\".\"account_id\" = 4 AND \"groups\".\"id\" = \"group_items\".\"group_id\" WHERE \"group_items\".\"account_id\" = 4 AND (LOWER(CAST(\"groups\".\"lms_data->>'name'\" AS CHAR(256))) LIKE '%adv%')"
However this throws an error :
The text was updated successfully, but these errors were encountered: