sequelize-typescript-generator 7.1.1 → 7.3.0
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.
|
@@ -59,7 +59,7 @@ class ModelBuilder extends Builder_1.Builder {
|
|
|
59
59
|
...col.allowNull && { allowNull: col.allowNull },
|
|
60
60
|
...col.dataType && { type: col.dataType },
|
|
61
61
|
...col.comment && { comment: col.comment },
|
|
62
|
-
...col.defaultValue !== undefined && { defaultValue: dialect.mapDefaultValueToSequelize(col.defaultValue
|
|
62
|
+
...col.defaultValue !== undefined && { defaultValue: dialect.mapDefaultValueToSequelize(col.defaultValue) },
|
|
63
63
|
};
|
|
64
64
|
return props;
|
|
65
65
|
};
|
package/build/builders/utils.js
CHANGED
|
@@ -43,7 +43,7 @@ const generateNamedImports = (importsSpecifier, moduleSpecifier) => {
|
|
|
43
43
|
/* decorators */ undefined,
|
|
44
44
|
/* modifiers */ undefined, ts.createImportClause(undefined, ts.createNamedImports([
|
|
45
45
|
...importsSpecifier
|
|
46
|
-
.map(is => ts.createImportSpecifier(undefined, ts.createIdentifier(is)))
|
|
46
|
+
.map(is => ts.createImportSpecifier(false, undefined, ts.createIdentifier(is)))
|
|
47
47
|
])), ts.createLiteral(moduleSpecifier));
|
|
48
48
|
};
|
|
49
49
|
exports.generateNamedImports = generateNamedImports;
|
|
@@ -63,10 +63,23 @@ exports.generateIndexExport = generateIndexExport;
|
|
|
63
63
|
* @return {ts.Decorator}
|
|
64
64
|
*/
|
|
65
65
|
const generateObjectLiteralDecorator = (decoratorIdentifier, props) => {
|
|
66
|
+
const _createPropertyAssignment = (propName, propValue) => {
|
|
67
|
+
let expression;
|
|
68
|
+
if (typeof propValue === 'number') {
|
|
69
|
+
expression = ts.createNumericLiteral(propValue);
|
|
70
|
+
}
|
|
71
|
+
else if (typeof propValue === 'string' && (propValue.startsWith('DataType.') || propValue.startsWith('Sequelize.'))) {
|
|
72
|
+
expression = ts.createIdentifier(propValue);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
expression = ts.createLiteral(propValue);
|
|
76
|
+
}
|
|
77
|
+
return ts.createPropertyAssignment(propName, expression);
|
|
78
|
+
};
|
|
66
79
|
return ts.createDecorator(ts.createCall(ts.createIdentifier(decoratorIdentifier), undefined, [
|
|
67
80
|
ts.createObjectLiteral([
|
|
68
81
|
...Object.entries(props)
|
|
69
|
-
.map(e =>
|
|
82
|
+
.map(e => _createPropertyAssignment(e[0], e[1]))
|
|
70
83
|
])
|
|
71
84
|
]));
|
|
72
85
|
};
|
|
@@ -160,7 +160,7 @@ class DialectPostgres extends Dialect_1.Dialect {
|
|
|
160
160
|
FROM pg_attribute a
|
|
161
161
|
LEFT OUTER JOIN pg_index x
|
|
162
162
|
ON a.attnum = ANY (x.indkey) AND a.attrelid = x.indrelid
|
|
163
|
-
WHERE a.attrelid = '${config.metadata.schema}
|
|
163
|
+
WHERE a.attrelid = '${config.metadata.schema}.\"${table}\"'::regclass AND a.attnum > 0
|
|
164
164
|
AND c.ordinal_position = a.attnum AND x.indisprimary IS TRUE
|
|
165
165
|
) AS is_primary,
|
|
166
166
|
c.*,
|
|
@@ -219,7 +219,7 @@ class DialectPostgres extends Dialect_1.Dialect {
|
|
|
219
219
|
comment: (_a = column.description) !== null && _a !== void 0 ? _a : undefined,
|
|
220
220
|
};
|
|
221
221
|
if (column.column_default) {
|
|
222
|
-
columnMetadata.defaultValue = `Sequelize.literal("${column.column_default}")`;
|
|
222
|
+
columnMetadata.defaultValue = `Sequelize.literal("${column.column_default.replace(/\"/g, '\\\"')}")`;
|
|
223
223
|
}
|
|
224
224
|
// Additional data type information
|
|
225
225
|
switch (column.udt_name) {
|
|
@@ -268,7 +268,7 @@ class DialectPostgres extends Dialect_1.Dialect {
|
|
|
268
268
|
ON x.indexrelid = pc.oid
|
|
269
269
|
INNER JOIN pg_am am
|
|
270
270
|
ON pc.relam = am.oid
|
|
271
|
-
WHERE a.attrelid = '${config.metadata.schema}
|
|
271
|
+
WHERE a.attrelid = '${config.metadata.schema}.\"${table}\"'::regclass AND a.attnum > 0
|
|
272
272
|
AND a.attname = '${column}';
|
|
273
273
|
`;
|
|
274
274
|
const indices = await connection.query(query, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sequelize-typescript-generator",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.3.0",
|
|
4
4
|
"description": "Automatically generates typescript models compatible with sequelize-typescript library (https://www.npmjs.com/package/sequelize-typescript) directly from your source database.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -35,33 +35,33 @@
|
|
|
35
35
|
"homepage": "https://github.com/spinlud/sequelize-typescript-generator.git#readme",
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/bluebird": "^3.5.36",
|
|
38
|
-
"@types/jest": "^27.0
|
|
39
|
-
"@types/node": "^
|
|
38
|
+
"@types/jest": "^27.4.0",
|
|
39
|
+
"@types/node": "^17.0.8",
|
|
40
40
|
"@types/pluralize": "0.0.29",
|
|
41
|
-
"@types/validator": "^13.
|
|
42
|
-
"@types/yargs": "^17.0.
|
|
43
|
-
"jest": "^27.
|
|
44
|
-
"mariadb": "^2.5.
|
|
45
|
-
"mysql2": "^2.3.
|
|
41
|
+
"@types/validator": "^13.7.1",
|
|
42
|
+
"@types/yargs": "^17.0.8",
|
|
43
|
+
"jest": "^27.4.7",
|
|
44
|
+
"mariadb": "^2.5.5",
|
|
45
|
+
"mysql2": "^2.3.3",
|
|
46
46
|
"pg": "^8.7.1",
|
|
47
47
|
"pg-hstore": "^2.3.4",
|
|
48
48
|
"reflect-metadata": "^0.1.13",
|
|
49
49
|
"sqlite3": "^4.2.0",
|
|
50
|
-
"tedious": "^
|
|
51
|
-
"ts-jest": "^27.
|
|
50
|
+
"tedious": "^14.0.0",
|
|
51
|
+
"ts-jest": "^27.1.2",
|
|
52
52
|
"ts-node-dev": "^1.1.8",
|
|
53
|
-
"typescript": "^4.
|
|
53
|
+
"typescript": "^4.5.4",
|
|
54
54
|
"wkx": "^0.5.0"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@types/eslint": "^
|
|
58
|
-
"@typescript-eslint/parser": "^5.
|
|
57
|
+
"@types/eslint": "^8.2.2",
|
|
58
|
+
"@typescript-eslint/parser": "^5.9.0",
|
|
59
59
|
"change-case": "^4.1.2",
|
|
60
|
-
"eslint": "^8.0
|
|
60
|
+
"eslint": "^8.6.0",
|
|
61
61
|
"pluralize": "^8.0.0",
|
|
62
|
-
"sequelize": "^6.
|
|
63
|
-
"sequelize-typescript": "^2.1.
|
|
64
|
-
"yargs": "^17.
|
|
62
|
+
"sequelize": "^6.12.5",
|
|
63
|
+
"sequelize-typescript": "^2.1.2",
|
|
64
|
+
"yargs": "^17.3.1"
|
|
65
65
|
},
|
|
66
66
|
"keywords": [
|
|
67
67
|
"sequelize",
|