Skip to content

fix(ExpressionBuilder): improper custom operator support in eb().#1579

Merged
igalklebanov merged 1 commit intokysely-org:masterfrom
igalklebanov:eb-custom-op-inference
Sep 14, 2025
Merged

fix(ExpressionBuilder): improper custom operator support in eb().#1579
igalklebanov merged 1 commit intokysely-org:masterfrom
igalklebanov:eb-custom-op-inference

Conversation

@igalklebanov
Copy link
Copy Markdown
Member

@igalklebanov igalklebanov commented Sep 14, 2025

Hey 👋

closes #891.

This PR makes it so that the following is assignable to Expression<SqlBool>:

eb('age', sql`OP`, 1)

Where before it would inherit the type from the first argument, and fail when it was not assignable to SqlBool in common contexts.

This was also true when explicitly providing the custom operator a return type.

So now, as an experiment, we'll allow you to dictate the binary expression's return type:

expectAssignable<Expression<SqlBool>>(eb('age', sql<SqlBool>`OP`, 1)) 
expectAssignable<Expression<number>>(eb('age', sql<number>`OP`, 1))
expectAssignable<Expression<string>>(eb('age', sql<string>`OP`, 1))

@igalklebanov igalklebanov added api Related to library's API bug Something isn't working enhancement New feature or request typescript Related to Typescript labels Sep 14, 2025
@vercel
Copy link
Copy Markdown

vercel Bot commented Sep 14, 2025

@igalklebanov is attempting to deploy a commit to the Kysely Team Team on Vercel.

A member of the Team first needs to authorize it.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Sep 14, 2025

kysely_koa_example

npm i https://pkg.pr.new/kysely-org/kysely@1579

commit: 8344731

@igalklebanov igalklebanov changed the title feat(ExpressionBuilder): allow to control eb() expression type with custom operators. feat(ExpressionBuilder): custom operator support in eb(). Sep 14, 2025
@igalklebanov igalklebanov changed the title feat(ExpressionBuilder): custom operator support in eb(). feat(ExpressionBuilder): proper custom operator support in eb(). Sep 14, 2025
@igalklebanov igalklebanov changed the title feat(ExpressionBuilder): proper custom operator support in eb(). fix(ExpressionBuilder): improper custom operator support in eb(). Sep 14, 2025
@igalklebanov igalklebanov merged commit 3f1db74 into kysely-org:master Sep 14, 2025
26 of 28 checks passed
@igalklebanov igalklebanov deleted the eb-custom-op-inference branch September 14, 2025 00:44
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 bug Something isn't working enhancement New feature or request typescript Related to Typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

eb assumes unknown operators to be arithmetic operators

1 participant