Skip to content

Commit 4ec2def

Browse files
committed
fixed drizzle-seed
1 parent 7a6a517 commit 4ec2def

File tree

12 files changed

+27
-24
lines changed

12 files changed

+27
-24
lines changed

drizzle-orm/src/singlestore-core/columns/vector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class SingleStoreBigIntVector<T extends ColumnBaseConfig<'array int64vect
134134
readonly elementType = 'I64';
135135

136136
getSQLType(): string {
137-
return `vector(${this.config.length}, ${this.elementType}})`;
137+
return `vector(${this.config.length}, ${this.elementType})`;
138138
}
139139

140140
override mapToDriverValue(value: Array<bigint>): string {

drizzle-seed/src/cockroach-core/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export const mapCockroachTable = (
103103
name: baseColumn.name,
104104
columnType: baseColumn.getSQLType(),
105105
typeParams: getTypeParams(baseColumn.getSQLType()),
106-
dataType: baseColumn.dataType,
106+
dataType: baseColumn.dataType.split(' ')[0]!,
107107
size: (baseColumn as CockroachArray<any, any>).length,
108108
hasDefault: baseColumn.hasDefault,
109109
enumValues: baseColumn.enumValues,
@@ -165,7 +165,7 @@ export const mapCockroachTable = (
165165
name: dbToTsColumnNamesMap[column.name] as string,
166166
columnType: column.getSQLType(),
167167
typeParams: getTypeParams(column.getSQLType()),
168-
dataType: column.dataType,
168+
dataType: column.dataType.split(' ')[0]!,
169169
size: (column as CockroachArray<any, any>).length,
170170
hasDefault: column.hasDefault,
171171
default: column.default,

drizzle-seed/src/common.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getColumnTable, getTableName, is } from 'drizzle-orm';
1+
import { Column as DrizzleColumn, getColumnTable, getTableName, is } from 'drizzle-orm';
22
import {
33
createTableRelationsHelpers,
44
extractTablesRelationalConfig,
@@ -129,7 +129,7 @@ export const getSchemaInfo = (
129129

130130
const tableConfig = getTableConfig(table);
131131
for (const [tsCol, col] of Object.entries(getColumnTable(tableConfig.columns[0]!))) {
132-
dbToTsColumnNamesMap[col.name] = tsCol;
132+
if (is(col, DrizzleColumn)) dbToTsColumnNamesMap[col.name] = tsCol;
133133
}
134134
dbToTsColumnNamesMapGlobal[tableName] = dbToTsColumnNamesMap;
135135

@@ -139,10 +139,7 @@ export const getSchemaInfo = (
139139
for (const table of Object.values(drizzleTables)) {
140140
tableConfig = getTableConfig(table);
141141

142-
dbToTsColumnNamesMap = {};
143-
for (const [tsCol, col] of Object.entries(getColumnTable(tableConfig.columns[0]!))) {
144-
dbToTsColumnNamesMap[col.name] = tsCol;
145-
}
142+
dbToTsColumnNamesMap = getDbToTsColumnNamesMap(table);
146143

147144
// might be empty list
148145
const newRelations = tableConfig.foreignKeys === undefined ? [] : tableConfig.foreignKeys.map((fk) => {

drizzle-seed/src/generators/Generators.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,6 +1481,8 @@ export class GenerateString extends AbstractGenerator<{
14811481
);
14821482
currStr += stringChars[idx];
14831483
}
1484+
1485+
if (this.dataType === 'object') return Buffer.from(currStr);
14841486
return currStr;
14851487
}
14861488
}
@@ -1525,7 +1527,10 @@ export class GenerateUniqueString extends AbstractGenerator<{ isUnique?: boolean
15251527
currStr += stringChars[idx];
15261528
}
15271529

1528-
return currStr.slice(0, 4) + uniqueStr + currStr.slice(4);
1530+
currStr = currStr.slice(0, 4) + uniqueStr + currStr.slice(4);
1531+
1532+
if (this.dataType === 'object') return Buffer.from(currStr);
1533+
return currStr;
15291534
}
15301535
}
15311536

@@ -2937,7 +2942,7 @@ export class GeneratePoint extends AbstractGenerator<{
29372942
const x = this.state.xCoordinateGen.generate();
29382943
const y = this.state.yCoordinateGen.generate();
29392944

2940-
if (this.dataType === 'json') {
2945+
if (this.dataType === 'object') {
29412946
return { x, y };
29422947
} else if (this.dataType === 'string') {
29432948
return `[${x}, ${y}]`;
@@ -2990,7 +2995,7 @@ export class GenerateUniquePoint extends AbstractGenerator<{
29902995
const x = this.state.xCoordinateGen.generate();
29912996
const y = this.state.yCoordinateGen.generate();
29922997

2993-
if (this.dataType === 'json') {
2998+
if (this.dataType === 'object') {
29942999
return { x, y };
29953000
} else if (this.dataType === 'string') {
29963001
return `[${x}, ${y}]`;
@@ -3062,7 +3067,7 @@ export class GenerateLine extends AbstractGenerator<{
30623067

30633068
const c = this.state.cCoefficientGen.generate();
30643069

3065-
if (this.dataType === 'json') {
3070+
if (this.dataType === 'object') {
30663071
return { a, b, c };
30673072
} else if (this.dataType === 'string') {
30683073
return `[${a}, ${b}, ${c}]`;
@@ -3132,7 +3137,7 @@ export class GenerateUniqueLine extends AbstractGenerator<{
31323137

31333138
const c = this.state.cCoefficientGen.generate();
31343139

3135-
if (this.dataType === 'json') {
3140+
if (this.dataType === 'object') {
31363141
return { a, b, c };
31373142
} else if (this.dataType === 'string') {
31383143
return `[${a}, ${b}, ${c}]`;

drizzle-seed/src/generators/versioning/v2.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export class GenerateStringV2 extends AbstractGenerator<{
165165
currStr += stringChars[idx];
166166
}
167167

168-
if (this.dataType === 'buffer') return Buffer.from(currStr);
168+
if (this.dataType === 'object') return Buffer.from(currStr);
169169
return currStr;
170170
}
171171
}
@@ -229,6 +229,7 @@ export class GenerateUniqueStringV2 extends AbstractGenerator<{ isUnique?: boole
229229
currStr += stringChars[idx];
230230
}
231231

232+
if (this.dataType === 'object') return Buffer.from(uniqueStr + currStr);
232233
return uniqueStr + currStr;
233234
}
234235
}

drizzle-seed/src/mssql-core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ const mapMsSqlTable = (
246246
name: dbToTsColumnNamesMap[column.name] as string,
247247
columnType: column.getSQLType(),
248248
typeParams: getTypeParams(column.getSQLType()),
249-
dataType: column.dataType,
249+
dataType: column.dataType.split(' ')[0]!,
250250
hasDefault: column.hasDefault,
251251
default: column.default,
252252
enumValues: column.enumValues,

drizzle-seed/src/mysql-core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export const mapMySqlTable = (
140140
name: dbToTsColumnNamesMap[column.name] as string,
141141
columnType: column.getSQLType(),
142142
typeParams: getTypeParams(column.getSQLType()),
143-
dataType: column.dataType,
143+
dataType: column.dataType.split(' ')[0]!,
144144
hasDefault: column.hasDefault,
145145
default: column.default,
146146
enumValues: column.enumValues,

drizzle-seed/src/pg-core/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export const mapPgTable = (
104104
name: baseColumn.name,
105105
columnType: baseColumn.getSQLType(),
106106
typeParams: getTypeParams(baseColumn.getSQLType()),
107-
dataType: baseColumn.dataType,
107+
dataType: baseColumn.dataType.split(' ')[0]!,
108108
size: (baseColumn as PgArray<any, any>).length,
109109
hasDefault: baseColumn.hasDefault,
110110
enumValues: baseColumn.enumValues,
@@ -166,7 +166,7 @@ export const mapPgTable = (
166166
name: dbToTsColumnNamesMap[column.name] as string,
167167
columnType: column.getSQLType(),
168168
typeParams: getTypeParams(column.getSQLType()),
169-
dataType: column.dataType,
169+
dataType: column.dataType.split(' ')[0]!,
170170
size: (column as PgArray<any, any>).length,
171171
hasDefault: column.hasDefault,
172172
default: column.default,

drizzle-seed/src/singlestore-core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export const mapSingleStoreTable = (
146146
name: dbToTsColumnNamesMap[column.name] as string,
147147
columnType: column.getSQLType(),
148148
typeParams: getTypeParams(column.getSQLType()),
149-
dataType: column.dataType,
149+
dataType: column.dataType.split(' ')[0]!,
150150
hasDefault: column.hasDefault,
151151
default: column.default,
152152
enumValues: column.enumValues,

drizzle-seed/src/sqlite-core/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export const mapSqliteTable = (
134134
name: dbToTsColumnNamesMap[column.name] as string,
135135
columnType: column.getSQLType(),
136136
typeParams: getTypeParams(column.getSQLType()),
137-
dataType: column.dataType,
137+
dataType: column.dataType.split(' ')[0]!,
138138
hasDefault: column.hasDefault,
139139
default: column.default,
140140
enumValues: column.enumValues,

0 commit comments

Comments
 (0)