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

Allow string argument when regexp- or like-ing an enum column #1330

Open
twiddler opened this issue Jan 22, 2025 · 1 comment
Open

Allow string argument when regexp- or like-ing an enum column #1330

twiddler opened this issue Jan 22, 2025 · 1 comment
Labels
api Related to library's API enhancement New feature or request typescript Related to Typescript

Comments

@twiddler
Copy link
Contributor

When filtering an enum column, e.g.

interface Database {
  Pet: {
    species: "dog" | "cat" | "hamster";
  };
}

with "regexp" or "like"

db.selectFrom("Pet")
  .where("species", "regexp", "ste") // ❌ Argument of type '"ste"' is not assignable to parameter of type 'OperandValueExpressionOrList<Database, "Pet", "species">'.(2345)
  .where("species", "like", "%ste%") // ❌ Argument of type '"%ste%"' is not assignable to parameter of type 'OperandValueExpressionOrList<Database, "Pet", "species">'.(2345)

the types leading to the type errors above seem too strict to me.

What do you think about broadening the type to string for the right-hand side argument of "regexp" and "like"?

Playground link

@igalklebanov igalklebanov added enhancement New feature or request api Related to library's API typescript Related to Typescript labels Jan 22, 2025
@koskimas
Copy link
Member

koskimas commented Jan 26, 2025

This is related to #1333. As explained there, we don't currently have any operator spcific behavior. But this is definitely another case where it's needed.

You can get around this issue using something like this https://kyse.link/VjgoI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Related to library's API enhancement New feature or request typescript Related to Typescript
Projects
None yet
Development

No branches or pull requests

3 participants