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

add varbinary data type for mysql #812

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/operation-node/data-type-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const SIMPLE_COLUMN_DATA_TYPES = [
'json',
'jsonb',
'blob',
'varbinary',
] as const

const COLUMN_DATA_TYPE_REGEX = [
Expand All @@ -45,6 +46,7 @@ const COLUMN_DATA_TYPE_REGEX = [
/^timetz\(\d+\)$/,
/^timestamp\(\d+\)$/,
/^timestamptz\(\d+\)$/,
/^varbinary\(\d+\)$/,
]

type SimpleColumnDataType = (typeof SIMPLE_COLUMN_DATA_TYPES)[number]
Expand All @@ -61,6 +63,7 @@ export type ColumnDataType =
| `timetz(${number})`
| `timestamp(${number})`
| `timestamptz(${number})`
| `varbinary(${number})`

export type DataTypeParams = Omit<DataTypeNode, 'kind' | 'dataType'>

Expand Down
10 changes: 8 additions & 2 deletions test/node/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ for (const dialect of DIALECTS) {
.addColumn('t', 'char(4)')
.addColumn('u', 'char')
.addColumn('v', 'binary(16)')
.addColumn('w', 'varbinary(16)')

testSql(builder, dialect, {
mysql: {
Expand All @@ -258,7 +259,8 @@ for (const dialect of DIALECTS) {
'`s` timestamp(6) default current_timestamp(6) not null,',
'`t` char(4),',
'`u` char,',
'`v` binary(16))',
'`v` binary(16),',
'`w` varbinary(16))',
],
parameters: [],
},
Expand Down Expand Up @@ -337,6 +339,8 @@ for (const dialect of DIALECTS) {
.addColumn('w', 'char')
.addColumn('x', 'binary')
.addColumn('y', sql``, (col) => col.modifyEnd(sql`as (a + f)`))
.addColumn('z', 'varbinary')
.addColumn('aa', 'varbinary(16)')

testSql(builder, dialect, {
mssql: {
Expand Down Expand Up @@ -366,7 +370,9 @@ for (const dialect of DIALECTS) {
'"v" char(4),',
'"w" char,',
'"x" binary,',
'"y" as (a + f))',
'"y" as (a + f),',
'"z" varbinary,',
'"aa" varbinary(16))',
],
parameters: [],
},
Expand Down