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

Cast issues with enums #667

Closed
SteelAlloy opened this issue Jul 29, 2023 · 1 comment
Closed

Cast issues with enums #667

SteelAlloy opened this issue Jul 29, 2023 · 1 comment

Comments

@SteelAlloy
Copy link

The following issue is a repost of SeaQL/sea-orm#1527, since this issue actually belongs here.

I've also encountered the bug with gte : `"operator does not exist: some_enum >= text".


Description

.is_in(...) and .is_not_in(...) don't use CAST when comparing enums.

gte as well and other operators I guess.

Steps to Reproduce

  1. Create a table in Postgres, that has a field with custom type as enum.
  2. Make a query to that table, having a condition of this enum field IN vector.

Expected Behavior

The same as with .eq, .ne operators. Resulting query should look something like this.

-- For .eq operator, it generates correctly
WHERE "table"."enum_field" = CAST($1 AS enum_type)
-- For .is_in operator, it generates a different query without CAST
WHERE "table"."enum_field" IN (CAST($1 AS enum_type), CAST($2 AS enum_type))

Actual Behavior

Generated query looks something like this

WHERE "table"."enum_field" IN ($1, $2)

PgDatabaseError is returned.

{severity: Error, code: "42883", message: "operator does not exist: enum_type <> text", ...}

Reproduces How Often

Always, I assume. But the bug was spoted when in subquery.

Versions

sea-orm v0.11.0
postgres
macos Ventura

sea-orm v0.12.1
postgres
ubuntu 22

Additional Information

cc @0xAndoroid

@tyt2y3
Copy link
Member

tyt2y3 commented Aug 31, 2023

I think this is a bug only in SeaORM, as all cast as is applied by the ORM. I don't think there is any limitation in SeaQuery.

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

2 participants