https://kotlinlang.org logo
#exposed
Title
# exposed
j

John Pena

04/19/2021, 8:36 PM
i get errors with the following error message when i try to query using an enum value:
Copy code
Transaction attempt #0 failed: org.postgresql.util.PSQLException: ERROR: operator does not exist: "MyEnumColumn" = character varying\n  Hint: No operator matches the given name and argument types. You might need to add explicit type casts
e

Emil Kantis

04/19/2021, 8:40 PM
Would be helpful to share the generated query and perhaps the DSL used to generate the query 🙂
j

John Pena

04/19/2021, 8:47 PM
@Emil Kantis done
e

Emil Kantis

04/19/2021, 8:48 PM
taking a look, I'm also using it in postgres with similar query etc
it could be helpful to others to keep things in a thread btw 🙂
j

John Pena

04/19/2021, 8:48 PM
cool, thanks for your help!
e

Emil Kantis

04/19/2021, 8:53 PM
did you create your schema using exposed?
If you check the table definition, is it something like this ?
Copy code
create table my_things
(
	my_field varchar(32) character varying not null,
);
j

John Pena

04/19/2021, 8:55 PM
looking
i did not create the schema with exposed
CREATE TYPE "public"."MyField" AS ENUM ('X', 'Y', 'Z');
Copy code
-- Table Definition
CREATE TABLE "public"."MyTable" (
    "myField" "public"."MyField" NOT NULL
)
e

Emil Kantis

04/19/2021, 8:59 PM
if you try changing the table to the following, it would probably™ be fine
Copy code
CREATE TABLE "public"."MyTable" (
    "myField" varchar(32) NOT NULL
)
j

John Pena

04/19/2021, 9:00 PM
yeah if i can’t figure this out then that’ll be my solution, just use a varchar or an int
but it “seems” like it should work, given that it’s issuing the proper query
e

Emil Kantis

04/19/2021, 9:01 PM
maybe when you run the query manually your client infers that it's the enum value 'x' you refer to, whereas the query sent from postgres is executed as-is, thus comparing the enum to a varchar which is not valid
which would sort of make sense.. not sure if there's any way around it though..
This guy seems to have managed to do something similar.. 🙂 https://github.com/JetBrains/Exposed/issues/609
j

John Pena

04/19/2021, 9:06 PM
“Workaround update: avoiding the DAO DSL with all the same existing classes works :)”
might also be an option
@Emil Kantis thanks for your help, looks like i have a few options
👍 1
3 Views