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

PG::UndefinedFunction - function COUNT() w/ multiple arguments doesn't exist in PG #165

Open
brunnopleffken opened this issue Jul 23, 2024 · 1 comment

Comments

@brunnopleffken
Copy link

I'm trying to export the data in the following PostgreSQL table as a seed:

Screenshot 2024-07-23 at 09 08 39

As you can see, nothing fancy.

However, I'm getting the error:

bin/rails aborted!
ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  function count(bigint, character varying, character varying) does not exist (ActiveRecord::StatementInvalid)
LINE 1: SELECT COUNT(id, name, class_entity) FROM "professions"
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.


Caused by:
PG::UndefinedFunction: ERROR:  function count(bigint, character varying, character varying) does not exist (PG::UndefinedFunction)
LINE 1: SELECT COUNT(id, name, class_entity) FROM "professions"
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

Tasks: TOP => db:seed:dump
(See full trace by running task with --trace)

Why is seed_dump using COUNT passing multiple columns as arguments in PostgreSQL? This doesn't work.

And this is strange because it's the first time I've seen this error using seed_dump.

@brunnopleffken
Copy link
Author

brunnopleffken commented Jul 23, 2024

I found out what's going on.

seed_dump is conflicting with the model:

default_scope { select(:id, :name, :class_entity) }

Temporarily commenting this line makes it work.

Shouldn't seed_dump unscope queries?

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

1 participant