drizzle-team / drizzle-team/drizzle-orm
[BUG]: drizzle-arktype mishandles char 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?
0.42.0
### What version of `drizzle-kit` are you using?
0.31.0
### Other packages
drizzle-arktype@0.1.2
### Describe the Bug
#### Undesired Behaviour
In drizzle-arktype, the generated schemas require char columns to be of an exact length, however (at least in MySQL) this is not a requirement of the database engine; whilst the stored values are right-padded to the specified length, they are trimmed when retrieved.
#### Reproduction
```ts
// schema.ts
import { char, mysqlTable } from 'drizzle-orm/mysql-core';
import { createSelectSchema } from 'drizzle-arktype';
export const t = mysqlTable('t', {
id: char('id', { length: 8 }).notNull(),
});
export const selectT = createSelectSchema(t);
// index.ts
import { drizzle } from 'drizzle-orm/mysql2';
import * as schema from './schema';
const db = drizzle(process.env.DATABASE_URL, { mode: 'default', schema });
await db.insert(schema.t).values({ id: 'AAAAAAA' });
const out = schema.selectT(await db.query.t.findFirst());
// ^? const out: ArkErrors
// out.summary: id must be exactly length 8 (was 7)
```
#### Desired Result
```ts
const out = schema.selectT(await db.query.t.findFirst());
// ^? const out: { id: string; }
```
Contributor guide
Assessment
This issue has not been assessed yet.