drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-arktype createSelectSchema typing doesn't accept refinements for custom columns
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [x] I have verified that the bug I'm about to report hasn't been filed before.
### What version of `drizzle-orm` are you using?
1.0.0-beta.10
### What version of `drizzle-kit` are you using?
1.0.0-beta.10
### Other packages
drizzle-arktype 1.0.0-beta.10
### Describe the Bug
If I specify a view field like:
```ts
{ x: sql`${t.x} * 2`.as('x') }
```
and then try to create a refinement for createSelectSchema to type column `x` like:
```ts
createSelectSchema(myView, { x: type.number })
```
then Typescript complains with:
`Object literal may only specify known properties, and 'x' does not exist in type 'NoUnknownKeys>'`
Typescript is satisfied if I get rid of the `.as('x')`, but then queries don't work:
`error: You tried to reference "x" field from a subquery, which is a raw SQL field, but it doesn't have an alias declared. Please add an alias to the field using ".as('alias')" method.`
I've also tried various versions of aliasing to different names (e.g. `.as('y')` and/or using 'y' as the key in the refinement) to no avail.
Typescript 5.9.3
bun-sqlite on Bun 1.3.5, not sure if affects other dialects etc.
Contributor guide
Assessment
This issue has not been assessed yet.