2

Here's my code:

.having('(COUNT(DISTINCT taggings.tag_id) = 0 OR array[?] <@ array_agg(taggings.tag_id))', tag_ids)

I am getting the followint error when executing the above query:

ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR:  operator does not exist: text[] <@ integer[]
LINE 1: ...OUNT(DISTINCT taggings.tag_id) = 0 OR array[NULL] <@ array_a...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.

I'm new to the postgresql, can anyone please point the solution?

1 Answer 1

3

You should explicitly cast the array to int[], because array[null] is resolved as text[].

... OR array[?]::int[] <@ array_agg(taggings.tag_id)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.