@mikro-orm/mssql 6.1.13-dev.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/MsSqlConnection.d.ts +14 -0
- package/MsSqlConnection.js +61 -0
- package/MsSqlDriver.d.ts +9 -0
- package/MsSqlDriver.js +61 -0
- package/MsSqlExceptionConverter.d.ts +8 -0
- package/MsSqlExceptionConverter.js +37 -0
- package/MsSqlMikroORM.d.ts +19 -0
- package/MsSqlMikroORM.js +29 -0
- package/MsSqlPlatform.d.ts +47 -0
- package/MsSqlPlatform.js +171 -0
- package/MsSqlQueryBuilder.d.ts +9 -0
- package/MsSqlQueryBuilder.js +53 -0
- package/MsSqlSchemaGenerator.d.ts +6 -0
- package/MsSqlSchemaGenerator.js +31 -0
- package/MsSqlSchemaHelper.d.ts +32 -0
- package/MsSqlSchemaHelper.js +353 -0
- package/README.md +389 -0
- package/UnicodeStringType.d.ts +16 -0
- package/UnicodeStringType.js +49 -0
- package/index.d.ts +8 -0
- package/index.js +28 -0
- package/index.mjs +233 -0
- package/package.json +68 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MsSqlSchemaHelper = void 0;
|
|
4
|
+
const knex_1 = require("@mikro-orm/knex");
|
|
5
|
+
const UnicodeStringType_1 = require("./UnicodeStringType");
|
|
6
|
+
class MsSqlSchemaHelper extends knex_1.SchemaHelper {
|
|
7
|
+
static DEFAULT_VALUES = {
|
|
8
|
+
'true': ['1'],
|
|
9
|
+
'false': ['0'],
|
|
10
|
+
'getdate()': ['current_timestamp'],
|
|
11
|
+
};
|
|
12
|
+
getManagementDbName() {
|
|
13
|
+
return 'master';
|
|
14
|
+
}
|
|
15
|
+
disableForeignKeysSQL() {
|
|
16
|
+
return `exec sp_MSforeachtable 'alter table ? nocheck constraint all';`;
|
|
17
|
+
}
|
|
18
|
+
enableForeignKeysSQL() {
|
|
19
|
+
return `exec sp_MSforeachtable 'alter table ? check constraint all';`;
|
|
20
|
+
}
|
|
21
|
+
getDatabaseExistsSQL(name) {
|
|
22
|
+
return `select 1 from master.sys.databases where name = N'${name}'`;
|
|
23
|
+
}
|
|
24
|
+
getListTablesSQL() {
|
|
25
|
+
return `select t.name as table_name, schema_name(t2.schema_id) schema_name, ep.value as table_comment
|
|
26
|
+
from sysobjects t
|
|
27
|
+
inner join sys.tables t2 on t2.object_id = t.id
|
|
28
|
+
left join sys.extended_properties ep on ep.major_id = t.id and ep.name = 'MS_Description' and ep.minor_id = 0`;
|
|
29
|
+
}
|
|
30
|
+
normalizeDefaultValue(defaultValue, length, defaultValues = {}, stripQuotes = false) {
|
|
31
|
+
let match = defaultValue?.match(/^\((.*)\)$/);
|
|
32
|
+
if (match) {
|
|
33
|
+
defaultValue = match[1];
|
|
34
|
+
}
|
|
35
|
+
match = defaultValue?.match(/^\((.*)\)$/);
|
|
36
|
+
if (match) {
|
|
37
|
+
defaultValue = match[1];
|
|
38
|
+
}
|
|
39
|
+
match = defaultValue?.match(/^'(.*)'$/);
|
|
40
|
+
if (stripQuotes && match) {
|
|
41
|
+
defaultValue = match[1];
|
|
42
|
+
}
|
|
43
|
+
return super.normalizeDefaultValue(defaultValue, length, MsSqlSchemaHelper.DEFAULT_VALUES);
|
|
44
|
+
}
|
|
45
|
+
async getAllColumns(connection, tables) {
|
|
46
|
+
const sql = `select table_name as table_name,
|
|
47
|
+
table_schema as schema_name,
|
|
48
|
+
column_name as column_name,
|
|
49
|
+
column_default as column_default,
|
|
50
|
+
t4.value as column_comment,
|
|
51
|
+
ic.is_nullable as is_nullable,
|
|
52
|
+
data_type as data_type,
|
|
53
|
+
cmp.definition as generation_expression,
|
|
54
|
+
cmp.is_persisted as is_persisted,
|
|
55
|
+
numeric_precision as numeric_precision,
|
|
56
|
+
numeric_scale as numeric_scale,
|
|
57
|
+
coalesce(datetime_precision, character_maximum_length) length,
|
|
58
|
+
columnproperty(sc.object_id, column_name, 'IsIdentity') is_identity
|
|
59
|
+
from information_schema.columns ic
|
|
60
|
+
inner join sys.columns sc on sc.name = ic.column_name and sc.object_id = object_id(ic.table_schema + '.' + ic.table_name)
|
|
61
|
+
left join sys.computed_columns cmp on cmp.name = ic.column_name and cmp.object_id = object_id(ic.table_schema + '.' + ic.table_name)
|
|
62
|
+
left join sys.extended_properties t4 on t4.major_id = object_id(ic.table_schema + '.' + ic.table_name) and t4.name = 'MS_Description' and t4.minor_id = sc.column_id
|
|
63
|
+
where table_name in (${tables.map(t => this.platform.quoteValue(t.table_name))})
|
|
64
|
+
order by ordinal_position`;
|
|
65
|
+
const allColumns = await connection.execute(sql);
|
|
66
|
+
const str = (val) => val != null ? '' + val : val;
|
|
67
|
+
const ret = {};
|
|
68
|
+
for (const col of allColumns) {
|
|
69
|
+
const mappedType = this.platform.getMappedType(col.data_type);
|
|
70
|
+
const defaultValue = str(this.normalizeDefaultValue(col.column_default, col.length, {}, true));
|
|
71
|
+
const increments = col.is_identity === 1 && connection.getPlatform().isNumericColumn(mappedType);
|
|
72
|
+
const key = this.getTableKey(col);
|
|
73
|
+
/* istanbul ignore next */
|
|
74
|
+
const generated = col.generation_expression ? `${col.generation_expression}${col.is_persisted ? ' persisted' : ''}` : undefined;
|
|
75
|
+
let type = col.data_type;
|
|
76
|
+
if (col.length != null && !type.endsWith(`(${col.length})`)) {
|
|
77
|
+
type += `(${col.length})`;
|
|
78
|
+
}
|
|
79
|
+
if (type === 'numeric' && col.numeric_precision != null && col.numeric_scale != null) {
|
|
80
|
+
type += `(${col.numeric_precision},${col.numeric_scale})`;
|
|
81
|
+
}
|
|
82
|
+
ret[key] ??= [];
|
|
83
|
+
ret[key].push({
|
|
84
|
+
name: col.column_name,
|
|
85
|
+
type: this.platform.isNumericColumn(mappedType) ? col.data_type.replace(/ unsigned$/, '').replace(/\(\d+\)$/, '') : type,
|
|
86
|
+
mappedType,
|
|
87
|
+
unsigned: col.data_type.endsWith(' unsigned'),
|
|
88
|
+
length: col.length,
|
|
89
|
+
default: this.wrap(defaultValue, mappedType),
|
|
90
|
+
nullable: col.is_nullable === 'YES',
|
|
91
|
+
autoincrement: increments,
|
|
92
|
+
precision: col.numeric_precision,
|
|
93
|
+
scale: col.numeric_scale,
|
|
94
|
+
comment: col.column_comment,
|
|
95
|
+
generated,
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return ret;
|
|
99
|
+
}
|
|
100
|
+
async getAllIndexes(connection, tables) {
|
|
101
|
+
const sql = `select t.name as table_name,
|
|
102
|
+
ind.name as index_name,
|
|
103
|
+
is_unique as is_unique,
|
|
104
|
+
ind.is_primary_key as is_primary_key,
|
|
105
|
+
col.name as column_name,
|
|
106
|
+
schema_name(t.schema_id) as schema_name,
|
|
107
|
+
(case when filter_definition is not null then concat('where ', filter_definition) else null end) as expression
|
|
108
|
+
from sys.indexes ind
|
|
109
|
+
inner join sys.index_columns ic on ind.object_id = ic.object_id and ind.index_id = ic.index_id
|
|
110
|
+
inner join sys.columns col on ic.object_id = col.object_id and ic.column_id = col.column_id
|
|
111
|
+
inner join sys.tables t on ind.object_id = t.object_id
|
|
112
|
+
where
|
|
113
|
+
t.name in (${tables.map(t => this.platform.quoteValue(t.table_name)).join(', ')})
|
|
114
|
+
order by t.name, ind.name, ind.index_id`;
|
|
115
|
+
const allIndexes = await connection.execute(sql);
|
|
116
|
+
const ret = {};
|
|
117
|
+
for (const index of allIndexes) {
|
|
118
|
+
const key = this.getTableKey(index);
|
|
119
|
+
const indexDef = {
|
|
120
|
+
columnNames: [index.column_name],
|
|
121
|
+
keyName: index.index_name,
|
|
122
|
+
unique: index.is_unique,
|
|
123
|
+
primary: index.is_primary_key,
|
|
124
|
+
constraint: index.is_unique,
|
|
125
|
+
};
|
|
126
|
+
if (!index.column_name || index.column_name.match(/[(): ,"'`]/) || index.expression?.match(/where /i)) {
|
|
127
|
+
indexDef.expression = index.expression; // required for the `getCreateIndexSQL()` call
|
|
128
|
+
indexDef.expression = this.getCreateIndexSQL(index.table_name, indexDef, !!index.expression);
|
|
129
|
+
}
|
|
130
|
+
ret[key] ??= [];
|
|
131
|
+
ret[key].push(indexDef);
|
|
132
|
+
}
|
|
133
|
+
for (const key of Object.keys(ret)) {
|
|
134
|
+
ret[key] = await this.mapIndexes(ret[key]);
|
|
135
|
+
}
|
|
136
|
+
return ret;
|
|
137
|
+
}
|
|
138
|
+
mapForeignKeys(fks, tableName, schemaName) {
|
|
139
|
+
const ret = super.mapForeignKeys(fks, tableName, schemaName);
|
|
140
|
+
for (const fk of knex_1.Utils.values(ret)) {
|
|
141
|
+
fk.columnNames = knex_1.Utils.unique(fk.columnNames);
|
|
142
|
+
fk.referencedColumnNames = knex_1.Utils.unique(fk.referencedColumnNames);
|
|
143
|
+
}
|
|
144
|
+
return ret;
|
|
145
|
+
}
|
|
146
|
+
async getAllForeignKeys(connection, tables) {
|
|
147
|
+
const sql = `select ccu.constraint_name, ccu.table_name, ccu.table_schema schema_name, ccu.column_name,
|
|
148
|
+
kcu.constraint_schema referenced_schema_name,
|
|
149
|
+
kcu.column_name referenced_column_name,
|
|
150
|
+
kcu.table_name referenced_table_name,
|
|
151
|
+
rc.update_rule,
|
|
152
|
+
rc.delete_rule
|
|
153
|
+
from information_schema.constraint_column_usage ccu
|
|
154
|
+
inner join information_schema.referential_constraints rc on ccu.constraint_name = rc.constraint_name and rc.constraint_schema = ccu.constraint_schema
|
|
155
|
+
inner join information_schema.key_column_usage kcu on kcu.constraint_name = rc.unique_constraint_name and rc.unique_constraint_schema = kcu.constraint_schema
|
|
156
|
+
where (${tables.map(t => `(ccu.table_name = '${t.table_name}' and ccu.table_schema = '${t.schema_name}')`).join(' or ')})
|
|
157
|
+
order by kcu.table_schema, kcu.table_name, kcu.ordinal_position, kcu.constraint_name`;
|
|
158
|
+
const allFks = await connection.execute(sql);
|
|
159
|
+
const ret = {};
|
|
160
|
+
for (const fk of allFks) {
|
|
161
|
+
const key = this.getTableKey(fk);
|
|
162
|
+
ret[key] ??= [];
|
|
163
|
+
ret[key].push(fk);
|
|
164
|
+
}
|
|
165
|
+
Object.keys(ret).forEach(key => {
|
|
166
|
+
const [schemaName, tableName] = key.split('.');
|
|
167
|
+
ret[key] = this.mapForeignKeys(ret[key], tableName, schemaName);
|
|
168
|
+
});
|
|
169
|
+
return ret;
|
|
170
|
+
}
|
|
171
|
+
async getEnumDefinitions(connection, checks, tableName, schemaName) {
|
|
172
|
+
const found = [];
|
|
173
|
+
const enums = checks.reduce((o, item, index) => {
|
|
174
|
+
// check constraints are defined as one of:
|
|
175
|
+
// `([type]='owner' OR [type]='manager' OR [type]='employee')`
|
|
176
|
+
const m1 = item.definition?.match(/^check \((.*)\)/);
|
|
177
|
+
let items = m1?.[1].split(' OR ');
|
|
178
|
+
/* istanbul ignore next */
|
|
179
|
+
const hasItems = (items?.length ?? 0) > 0;
|
|
180
|
+
if (item.columnName && hasItems) {
|
|
181
|
+
items = items.map(val => val.trim().replace(`[${item.columnName}]=`, '').match(/^\(?'(.*)'/)?.[1]).filter(Boolean);
|
|
182
|
+
if (items.length > 0) {
|
|
183
|
+
o[item.columnName] = items.reverse();
|
|
184
|
+
found.push(index);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return o;
|
|
188
|
+
}, {});
|
|
189
|
+
found.reverse().forEach(index => checks.splice(index, 1));
|
|
190
|
+
return enums;
|
|
191
|
+
}
|
|
192
|
+
getChecksSQL(tables) {
|
|
193
|
+
return `select con.name as name,
|
|
194
|
+
schema_name(t.schema_id) schema_name,
|
|
195
|
+
t.name table_name,
|
|
196
|
+
col.name column_name,
|
|
197
|
+
con.definition expression
|
|
198
|
+
from sys.check_constraints con
|
|
199
|
+
left outer join sys.objects t on con.parent_object_id = t.object_id
|
|
200
|
+
left outer join sys.all_columns col on con.parent_column_id = col.column_id and con.parent_object_id = col.object_id
|
|
201
|
+
where (${tables.map(t => `t.name = '${t.table_name}' and schema_name(t.schema_id) = '${t.schema_name}'`).join(' or ')})
|
|
202
|
+
order by con.name`;
|
|
203
|
+
}
|
|
204
|
+
async getAllChecks(connection, tables) {
|
|
205
|
+
const sql = this.getChecksSQL(tables);
|
|
206
|
+
const allChecks = await connection.execute(sql);
|
|
207
|
+
const ret = {};
|
|
208
|
+
for (const check of allChecks) {
|
|
209
|
+
const key = this.getTableKey(check);
|
|
210
|
+
ret[key] ??= [];
|
|
211
|
+
ret[key].push({
|
|
212
|
+
name: check.name,
|
|
213
|
+
columnName: check.column_name,
|
|
214
|
+
definition: 'check ' + check.expression,
|
|
215
|
+
expression: check.expression,
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
return ret;
|
|
219
|
+
}
|
|
220
|
+
async loadInformationSchema(schema, connection, tables) {
|
|
221
|
+
if (tables.length === 0) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const columns = await this.getAllColumns(connection, tables);
|
|
225
|
+
const indexes = await this.getAllIndexes(connection, tables);
|
|
226
|
+
const checks = await this.getAllChecks(connection, tables);
|
|
227
|
+
const fks = await this.getAllForeignKeys(connection, tables);
|
|
228
|
+
for (const t of tables) {
|
|
229
|
+
const key = this.getTableKey(t);
|
|
230
|
+
const table = schema.addTable(t.table_name, t.schema_name, t.table_comment);
|
|
231
|
+
const pks = await this.getPrimaryKeys(connection, indexes[key], table.name, table.schema);
|
|
232
|
+
const enums = await this.getEnumDefinitions(connection, checks[key] ?? []);
|
|
233
|
+
table.init(columns[key], indexes[key], checks[key], pks, fks[key], enums);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
getPreAlterTable(tableDiff, safe) {
|
|
237
|
+
const ret = [];
|
|
238
|
+
const indexes = tableDiff.fromTable.getIndexes();
|
|
239
|
+
const parts = tableDiff.name.split('.');
|
|
240
|
+
const tableName = parts.pop();
|
|
241
|
+
const schemaName = parts.pop();
|
|
242
|
+
/* istanbul ignore next */
|
|
243
|
+
const name = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName;
|
|
244
|
+
const quotedName = this.platform.quoteIdentifier(name);
|
|
245
|
+
// indexes need to be first dropped to be able to change a column type
|
|
246
|
+
const changedTypes = Object.values(tableDiff.changedColumns).filter(col => col.changedProperties.has('type'));
|
|
247
|
+
// detect that the column was an enum before and remove the check constraint in such case here
|
|
248
|
+
const changedEnums = Object.values(tableDiff.changedColumns).filter(col => col.fromColumn.mappedType instanceof knex_1.EnumType);
|
|
249
|
+
for (const col of changedEnums) {
|
|
250
|
+
if (col.changedProperties.has('enumItems')) {
|
|
251
|
+
const checkName = this.platform.getConfig().getNamingStrategy().indexName(tableName, [col.column.name], 'check');
|
|
252
|
+
ret.push(`alter table ${quotedName} drop constraint if exists [${checkName}]`);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
for (const col of changedTypes) {
|
|
256
|
+
for (const index of indexes) {
|
|
257
|
+
if (index.columnNames.includes(col.column.name)) {
|
|
258
|
+
ret.push(this.getDropIndexSQL(name, index));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
// convert to string first if it's not already a string or has a smaller length
|
|
262
|
+
const type = this.platform.extractSimpleType(col.fromColumn.type);
|
|
263
|
+
if (!['varchar', 'nvarchar', 'varbinary'].includes(type) || (col.fromColumn.length < col.column.length)) {
|
|
264
|
+
ret.push(`alter table ${quotedName} alter column [${col.oldColumnName}] nvarchar(max)`);
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return ret.join(';\n');
|
|
268
|
+
}
|
|
269
|
+
getPostAlterTable(tableDiff, safe) {
|
|
270
|
+
const ret = [];
|
|
271
|
+
const indexes = tableDiff.fromTable.getIndexes();
|
|
272
|
+
const parts = tableDiff.name.split('.');
|
|
273
|
+
const tableName = parts.pop();
|
|
274
|
+
const schemaName = parts.pop();
|
|
275
|
+
/* istanbul ignore next */
|
|
276
|
+
const name = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName;
|
|
277
|
+
// indexes need to be first dropped to be able to change a column type
|
|
278
|
+
const changedTypes = Object.values(tableDiff.changedColumns).filter(col => col.changedProperties.has('type'));
|
|
279
|
+
for (const col of changedTypes) {
|
|
280
|
+
for (const index of indexes) {
|
|
281
|
+
if (index.columnNames.includes(col.column.name)) {
|
|
282
|
+
ret.push(this.getCreateIndexSQL(name, index));
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return ret.join(';\n');
|
|
287
|
+
}
|
|
288
|
+
getCreateNamespaceSQL(name) {
|
|
289
|
+
return `if (schema_id(${this.platform.quoteValue(name)}) is null) begin exec ('create schema ${this.platform.quoteIdentifier(name)} authorization [dbo]') end`;
|
|
290
|
+
}
|
|
291
|
+
getDropNamespaceSQL(name) {
|
|
292
|
+
return `drop schema if exists ${this.platform.quoteIdentifier(name)}`;
|
|
293
|
+
}
|
|
294
|
+
getDropIndexSQL(tableName, index) {
|
|
295
|
+
return `drop index ${this.platform.quoteIdentifier(index.keyName)} on ${this.platform.quoteIdentifier(tableName)}`;
|
|
296
|
+
}
|
|
297
|
+
getDropColumnsSQL(tableName, columns, schemaName) {
|
|
298
|
+
/* istanbul ignore next */
|
|
299
|
+
const tableNameRaw = this.platform.quoteIdentifier((schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName);
|
|
300
|
+
const drops = [];
|
|
301
|
+
const constraints = [];
|
|
302
|
+
let i = 0;
|
|
303
|
+
for (const column of columns) {
|
|
304
|
+
constraints.push(`declare @constraint${i} varchar(100) = (select default_constraints.name from sys.all_columns`
|
|
305
|
+
+ ' join sys.tables on all_columns.object_id = tables.object_id'
|
|
306
|
+
+ ' join sys.schemas on tables.schema_id = schemas.schema_id'
|
|
307
|
+
+ ' join sys.default_constraints on all_columns.default_object_id = default_constraints.object_id'
|
|
308
|
+
+ ` where schemas.name = '${schemaName}' and tables.name = '${tableName}' and all_columns.name = '${column.name}')`
|
|
309
|
+
+ ` if @constraint${i} is not null exec('alter table ${tableNameRaw} drop constraint ' + @constraint${i})`);
|
|
310
|
+
drops.push(this.platform.quoteIdentifier(column.name));
|
|
311
|
+
i++;
|
|
312
|
+
}
|
|
313
|
+
return `${constraints.join(';\n')};\nalter table ${tableNameRaw} drop column ${drops.join(', ')}`;
|
|
314
|
+
}
|
|
315
|
+
getRenameColumnSQL(tableName, oldColumnName, to, schemaName) {
|
|
316
|
+
/* istanbul ignore next */
|
|
317
|
+
const oldName = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName + '.' + oldColumnName;
|
|
318
|
+
const columnName = this.platform.quoteValue(to.name);
|
|
319
|
+
return `exec sp_rename ${this.platform.quoteValue(oldName)}, ${columnName}, 'COLUMN'`;
|
|
320
|
+
}
|
|
321
|
+
createTableColumn(table, column, fromTable, changedProperties, alter) {
|
|
322
|
+
if (changedProperties && column.mappedType instanceof knex_1.EnumType && column.enumItems?.every(item => knex_1.Utils.isString(item))) {
|
|
323
|
+
const checkName = this.platform.getConfig().getNamingStrategy().indexName(fromTable.name, [column.name], 'check');
|
|
324
|
+
if (changedProperties.has('enumItems')) {
|
|
325
|
+
table.check(`${this.platform.quoteIdentifier(column.name)} in ('${(column.enumItems.join("', '"))}')`, {}, this.platform.quoteIdentifier(checkName));
|
|
326
|
+
}
|
|
327
|
+
/* istanbul ignore next */
|
|
328
|
+
if (changedProperties.has('type')) {
|
|
329
|
+
return table.specificType(column.name, column.type);
|
|
330
|
+
}
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
if (column.generated) {
|
|
334
|
+
return table.specificType(column.name, `as ${column.generated}`);
|
|
335
|
+
}
|
|
336
|
+
return super.createTableColumn(table, column, fromTable, changedProperties);
|
|
337
|
+
}
|
|
338
|
+
inferLengthFromColumnType(type) {
|
|
339
|
+
const match = type.match(/n?varchar\((-?\d+|max)\)/);
|
|
340
|
+
if (!match) {
|
|
341
|
+
return undefined;
|
|
342
|
+
}
|
|
343
|
+
if (match[1] === 'max') {
|
|
344
|
+
return -1;
|
|
345
|
+
}
|
|
346
|
+
return +match[1];
|
|
347
|
+
}
|
|
348
|
+
wrap(val, type) {
|
|
349
|
+
const stringType = type instanceof knex_1.StringType || type instanceof knex_1.TextType || type instanceof knex_1.EnumType || type instanceof UnicodeStringType_1.UnicodeStringType;
|
|
350
|
+
return typeof val === 'string' && val.length > 0 && stringType ? this.platform.quoteValue(val) : val;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
exports.MsSqlSchemaHelper = MsSqlSchemaHelper;
|