Skip to content
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

Just adding this gem breaks PG gem #38

Open
mithucste30 opened this issue Nov 23, 2020 · 2 comments
Open

Just adding this gem breaks PG gem #38

mithucste30 opened this issue Nov 23, 2020 · 2 comments

Comments

@mithucste30
Copy link

mithucste30 commented Nov 23, 2020

ActiveRecord::StatementInvalid (PG::UndefinedObject: ERROR:  type "VARCHAR" does not exist
LINE 1: ...dio_clip_id" WHERE (CAST("collections"."title" AS "VARCHAR")...

Version: 2.0.13

full query

Rails version: 6.0.3.4
PG version: 1.2.3

(0.8ms)  SELECT
    COUNT( * ) AS "count_all"
    ,collections.id
    ,categories.name AS collections_id_categories_name
  FROM
    "collections" LEFT OUTER JOIN "categories"
      ON "categories" . "id" = "collections" . "category_id" LEFT OUTER JOIN "collection_tags"
      ON "collection_tags" . "collection_id" = "collections" . "id" LEFT OUTER JOIN "tags"
      ON "tags" . "id" = "collection_tags" . "tag_id" LEFT OUTER JOIN "taggings"
      ON "taggings" . "tag_id" = "tags" . "id" LEFT OUTER JOIN "audio_clips"
      ON "audio_clips" . "id" = "taggings" . "audio_clip_id"
  WHERE
    (
      CAST (
        "collections" . "title" AS "VARCHAR"
      ) ILIKE '%a%'
    )
    OR (
      CAST (
        "categories" . "name" AS "VARCHAR"
      ) ILIKE '%a%'
    )
  GROUP BY
    collections.id
    ,categories.name
  ORDER BY
    "collections" . "created_at" DESC

When using functionality with https://github.com/jbox-web/ajax-datatables-rails

@mithucste30 mithucste30 changed the title Adding this gem breaks PG gem Just adding this gem breaks PG gem Nov 23, 2020
@snex
Copy link

snex commented Dec 24, 2020

I am having the same issue. Also a different issue breaks group/aggregate queries. Will open a new issue for that.

@atruskie
Copy link
Contributor

I've hit the same error, it seems to be the 'AS' statement is followed by an extra ". In my case:

/lib/patches/db/pg.rb:69:in `exec_params': PG::SyntaxError: ERROR:  zero-length delimited identifier at or near """" (ActiveRecord::StatementInvalid)                               
LINE 1: ...AS "count_all", "analysis_jobs_items"."status" AS ""analysis... 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants