@mikro-orm/sql 7.2.3-dev.4 → 7.2.3-dev.5
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.
|
@@ -387,6 +387,8 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
387
387
|
data_type,
|
|
388
388
|
is_identity,
|
|
389
389
|
identity_generation,
|
|
390
|
+
identity_start,
|
|
391
|
+
identity_increment,
|
|
390
392
|
generation_expression,
|
|
391
393
|
pg_catalog.col_description(pgc.oid, cols.ordinal_position::int) column_comment,
|
|
392
394
|
coll.collname as collation_name
|
|
@@ -433,6 +435,14 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
433
435
|
type += `(${col.numeric_precision},${col.numeric_scale})`;
|
|
434
436
|
}
|
|
435
437
|
const length = this.inferLengthFromColumnType(type) === -1 ? -1 : col.length;
|
|
438
|
+
// a descending sequence starts at -1 by default
|
|
439
|
+
const defaultIdentityStart = col.identity_increment?.startsWith('-') ? '-1' : '1';
|
|
440
|
+
// read back non-default identity options, so `identity (start with 1000)` does not diff against plain `identity`
|
|
441
|
+
const identityOptions = [
|
|
442
|
+
col.identity_start !== defaultIdentityStart && `start with ${col.identity_start}`,
|
|
443
|
+
col.identity_increment !== '1' && `increment by ${col.identity_increment}`,
|
|
444
|
+
].filter(Boolean);
|
|
445
|
+
const identitySuffix = identityOptions.length > 0 ? ` (${identityOptions.join(' ')})` : '';
|
|
436
446
|
const column = {
|
|
437
447
|
name: col.column_name,
|
|
438
448
|
type,
|
|
@@ -445,9 +455,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
445
455
|
unsigned: increments,
|
|
446
456
|
autoincrement: increments,
|
|
447
457
|
generated: col.is_identity === 'YES'
|
|
448
|
-
? col.identity_generation === 'BY DEFAULT'
|
|
449
|
-
? 'by default as identity'
|
|
450
|
-
: 'identity'
|
|
458
|
+
? (col.identity_generation === 'BY DEFAULT' ? 'by default as identity' : 'identity') + identitySuffix
|
|
451
459
|
: col.generation_expression
|
|
452
460
|
? col.generation_expression + ' stored'
|
|
453
461
|
: undefined,
|
|
@@ -1032,7 +1040,7 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
1032
1040
|
columnType = this.quote(columnType);
|
|
1033
1041
|
}
|
|
1034
1042
|
}
|
|
1035
|
-
if (column.generated
|
|
1043
|
+
if (column.generated?.startsWith('by default as identity')) {
|
|
1036
1044
|
columnType += ` generated ${column.generated}`;
|
|
1037
1045
|
}
|
|
1038
1046
|
else if (column.generated) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.3-dev.
|
|
3
|
+
"version": "7.2.3-dev.5",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"data-mapper",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"@mikro-orm/core": "^7.2.2"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.3-dev.
|
|
56
|
+
"@mikro-orm/core": "7.2.3-dev.5"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|