diff --git a/drizzle-typebox/tests/pg.test.ts b/drizzle-typebox/tests/pg.test.ts index a9631614b..a9ef20a00 100644 --- a/drizzle-typebox/tests/pg.test.ts +++ b/drizzle-typebox/tests/pg.test.ts @@ -9,6 +9,7 @@ export const roleEnum = pgEnum('role', ['admin', 'user']); const users = pgTable('users', { a: integer('a').array(), + strArr: text('str_arr').array(), id: serial('id').primaryKey(), name: text('name'), email: text('email').notNull(), @@ -26,6 +27,7 @@ const users = pgTable('users', { const testUser = { a: [1, 2, 3], + strArr: ['one', 'two', 'three'], id: 1, name: 'John Doe', email: 'john.doe@example.com', @@ -92,6 +94,7 @@ test('users insert schema', (t) => { const expected = Type.Object({ a: Type.Optional(Nullable(Type.Array(Type.Number()))), + strArr: Type.Optional(Nullable(Type.Array(Type.String()))), id: Type.Optional(Type.Number({ minimum: 0 })), name: Type.Optional(Nullable(Type.String())), email: Type.String(), @@ -119,6 +122,7 @@ test('users insert schema w/ defaults', (t) => { const expected = Type.Object({ a: Type.Optional(Nullable(Type.Array(Type.Number()))), + strArr: Type.Optional(Nullable(Type.Array(Type.String()))), id: Type.Optional(Type.Number()), name: Type.Optional(Nullable(Type.String())), email: Type.String(), @@ -150,6 +154,7 @@ test('users select schema', (t) => { const expected = Type.Object({ a: Nullable(Type.Array(Type.Number())), + strArr: Nullable(Type.Array(Type.String())), id: Type.Number({ minimum: 0 }), name: Nullable(Type.String()), email: Type.String(), @@ -175,6 +180,7 @@ test('users select schema w/ defaults', (t) => { const expected = Type.Object({ a: Nullable(Type.Array(Type.Number())), + strArr: Nullable(Type.Array(Type.String())), id: Type.Number(), name: Nullable(Type.String()), email: Type.String(), diff --git a/drizzle-typebox/type-tests/mysql.ts b/drizzle-typebox/type-tests/mysql.ts deleted file mode 100644 index eb6b1bdcb..000000000 --- a/drizzle-typebox/type-tests/mysql.ts +++ /dev/null @@ -1,181 +0,0 @@ -import type { Static } from '@sinclair/typebox'; -import { - bigint, - binary, - boolean, - char, - customType, - date, - datetime, - decimal, - double, - float, - int, - json, - longtext, - mediumint, - mediumtext, - mysqlEnum, - mysqlTable, - real, - serial, - smallint, - text, - time, - timestamp, - tinyint, - tinytext, - varbinary, - varchar, - year, -} from 'drizzle-orm/mysql-core'; -import { createInsertSchema, createSelectSchema } from '../src'; -import { type Equal, Expect } from './utils'; - -const customInt = customType<{ data: number }>({ - dataType() { - return 'int'; - }, -}); - -const testTable = mysqlTable('test', { - bigint: bigint('bigint', { mode: 'bigint' }).notNull(), - bigintNumber: bigint('bigintNumber', { mode: 'number' }).notNull(), - binary: binary('binary').notNull(), - boolean: boolean('boolean').notNull(), - char: char('char', { length: 4 }).notNull(), - charEnum: char('char', { enum: ['a', 'b', 'c'] }).notNull(), - customInt: customInt('customInt').notNull(), - date: date('date').notNull(), - dateString: date('dateString', { mode: 'string' }).notNull(), - datetime: datetime('datetime').notNull(), - datetimeString: datetime('datetimeString', { mode: 'string' }).notNull(), - decimal: decimal('decimal').notNull(), - double: double('double').notNull(), - enum: mysqlEnum('enum', ['a', 'b', 'c']).notNull(), - float: float('float').notNull(), - int: int('int').notNull(), - json: json('json').notNull(), - mediumint: mediumint('mediumint').notNull(), - real: real('real').notNull(), - serial: serial('serial').notNull(), - smallint: smallint('smallint').notNull(), - text: text('text').notNull(), - textEnum: text('textEnum', { enum: ['a', 'b', 'c'] }).notNull(), - tinytext: tinytext('tinytext').notNull(), - tinytextEnum: tinytext('tinytextEnum', { enum: ['a', 'b', 'c'] }).notNull(), - mediumtext: mediumtext('mediumtext').notNull(), - mediumtextEnum: mediumtext('mediumtextEnum', { - enum: ['a', 'b', 'c'], - }).notNull(), - longtext: longtext('longtext').notNull(), - longtextEnum: longtext('longtextEnum', { enum: ['a', 'b', 'c'] }).notNull(), - time: time('time').notNull(), - timestamp: timestamp('timestamp').notNull(), - timestampString: timestamp('timestampString', { mode: 'string' }).notNull(), - tinyint: tinyint('tinyint').notNull(), - varbinary: varbinary('varbinary', { length: 200 }).notNull(), - varchar: varchar('varchar', { length: 200 }).notNull(), - varcharEnum: varchar('varcharEnum', { - length: 1, - enum: ['a', 'b', 'c'], - }).notNull(), - year: year('year').notNull(), - autoIncrement: int('autoIncrement').notNull().autoincrement(), -}); - -const insertSchema = createInsertSchema(testTable); -const selectSchema = createSelectSchema(testTable); - -type InsertType = Static; -type SelectType = Static; - -Expect< - Equal ->; - -Expect< - Equal ->; diff --git a/drizzle-typebox/type-tests/pg.ts b/drizzle-typebox/type-tests/pg.ts deleted file mode 100644 index fd381624b..000000000 --- a/drizzle-typebox/type-tests/pg.ts +++ /dev/null @@ -1,66 +0,0 @@ -import type { Static } from '@sinclair/typebox'; -import { char, date, integer, pgEnum, pgTable, serial, text, timestamp, varchar } from 'drizzle-orm/pg-core'; -import { createInsertSchema, createSelectSchema } from '../src'; -import { type Equal, Expect } from './utils'; - -export const roleEnum = pgEnum('role', ['admin', 'user']); - -const testTable = pgTable('users', { - intArr: integer('int_arr').array(), - strArr: text('str_arr').array(), - id: serial('id').primaryKey(), - name: text('name'), - email: text('email').notNull(), - birthdayString: date('birthday_string').notNull(), - birthdayDate: date('birthday_date', { mode: 'date' }).notNull(), - createdAt: timestamp('created_at').notNull().defaultNow(), - role: roleEnum('role').notNull(), - roleText: text('role1', { enum: ['admin', 'user'] }).notNull(), - roleText2: text('role2', { enum: ['admin', 'user'] }) - .notNull() - .default('user'), - profession: varchar('profession', { length: 20 }).notNull(), - initials: char('initials', { length: 2 }).notNull(), -}); - -const insertSchema = createInsertSchema(testTable); -const selectSchema = createSelectSchema(testTable); - -type InsertType = Static; -type SelectType = Static; - -Expect< - Equal ->; - -Expect< - Equal ->; diff --git a/drizzle-typebox/type-tests/sqlite.ts b/drizzle-typebox/type-tests/sqlite.ts deleted file mode 100644 index 1d172ce8f..000000000 --- a/drizzle-typebox/type-tests/sqlite.ts +++ /dev/null @@ -1,65 +0,0 @@ -import { type Static, Type } from '@sinclair/typebox'; -import { blob, integer, numeric, real, sqliteTable, text } from 'drizzle-orm/sqlite-core'; -import { createInsertSchema, createSelectSchema } from '../src'; -import { type Equal, Expect } from './utils'; - -const blobJsonSchema = Type.Object({ - foo: Type.String(), -}); - -const testTable = sqliteTable('users', { - id: integer('id').primaryKey(), - blobJson: blob('blob', { mode: 'json' }) - .$type>() - .notNull(), - blobBigInt: blob('blob', { mode: 'bigint' }).notNull(), - numeric: numeric('numeric').notNull(), - createdAt: integer('created_at', { mode: 'timestamp' }).notNull(), - createdAtMs: integer('created_at_ms', { mode: 'timestamp_ms' }).notNull(), - boolean: integer('boolean', { mode: 'boolean' }).notNull(), - real: real('real').notNull(), - text: text('text', { length: 255 }), - role: text('role', { enum: ['admin', 'user'] }) - .notNull() - .default('user'), -}); - -const insertSchema = createInsertSchema(testTable); -const selectSchema = createSelectSchema(testTable); - -type InsertType = Static; -type SelectType = Static; - -Expect< - Equal ->; - -Expect< - Equal ->; diff --git a/drizzle-typebox/type-tests/tsconfig.json b/drizzle-typebox/type-tests/tsconfig.json deleted file mode 100644 index b4e6c8007..000000000 --- a/drizzle-typebox/type-tests/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.build.json", - "compilerOptions": { - "composite": false, - "noEmit": true, - "rootDir": "..", - "outDir": "./.cache" - }, - "include": [".", "../src"], - "exclude": ["**/playground"] -} diff --git a/drizzle-typebox/type-tests/utils.ts b/drizzle-typebox/type-tests/utils.ts deleted file mode 100644 index 51b56d381..000000000 --- a/drizzle-typebox/type-tests/utils.ts +++ /dev/null @@ -1,5 +0,0 @@ -// eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-empty-function -export function Expect() {} - -export type Equal = (() => T extends X ? 1 : 2) extends (() => T extends Y ? 1 : 2) ? true - : false;