0

Can't seem to compare two (of the same) enum types. If I run the command...

SELECT 'test'::core.mytype = 'test'::core.mytype;

it gives the following error...

ERROR:  42725: operator is not unique: core.mytype = core.mytype
LINE 1: SELECT 'test'::core.mytype = 'test'::core.mytype;
                                   ^
HINT:  Could not choose a best candidate operator. You might need to add explicit type casts.
LOCATION:  op_error, parse_oper.c:718

If I try this on another Enum type I have, it works perfectly fine, just seems to be this particular type. Not only that, but I'm sure I've been using the comparison for a few weeks now in another function.

Is there something I'm missing, or may have possibly removed by accident?

7
  • Btw, using PostgreSQL 9.6. Commented Jun 24, 2019 at 8:29
  • Runs for me: dbfiddle.uk/… Maybe you could try to create a fiddle that shows the behaviour? Commented Jun 24, 2019 at 8:46
  • wish I could, but only seems to be this one particular enum type. I've even tried restarting the service just to be sure. Commented Jun 24, 2019 at 8:53
  • Also, there's no custom operators on it nor is it any different from all the other enum types that work. Commented Jun 24, 2019 at 8:54
  • can you show the type definition and the corresponding table definitions that are relevant for the query Commented Jun 24, 2019 at 8:58

1 Answer 1

1

So it seems that this was a result of a CAST function, which I still do not understand why.

There was an [implicit] CAST from the given type to JSON/JSONb. I am assuming that PostgreSQL was converting to JSONB/JSONB and comparing that and failing (which is understandable), but the error output mentioned nothing about JSON.

Anyway, after having removed the cast (or at least making it ON ASSIGNMENT), it seems to now work.

Crazy...but good to know.

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.