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

Kysely .any fails with expr must be an array when the column is Generated #184

Open
Exellin opened this issue Aug 16, 2024 · 0 comments
Open

Comments

@Exellin
Copy link

Exellin commented Aug 16, 2024

I have a table areas with a column days_of_week_active (for example ['Mon', 'Tue']).

In my schema the column is days_of_week_active: Generated<string[]>;, and it is generated because it has the default of all the days of the week:

.addColumn('days_of_week_active', sql`varchar(3)[]`, col => col.defaultTo(sql.raw(`ARRAY[${days_of_week.map(day => `'${day}'`).join(', ')}]`)).notNull())

The following example doesn't compile

  const monAreas = db.selectFrom('areas')
    .selectAll('areas')
    .where((eb) => eb(
      eb.val('Mon'), '=', eb.fn.any('areas.days_of_week_active')
    )).execute();

I get the following typescript error:

Argument of type 'KyselyTypeError<"any(expr) call failed: expr must be an array">' is not assignable to parameter of type 'OperandValueExpressionOrList<DB, "areas", ExpressionWrapper<DB, "areas", string>>'.

If I temporarily remove Generated from the schema and set it to string[], then it works fine.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
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

1 participant