@mikro-orm/sql 7.2.10-dev.9 → 7.2.11-dev.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.
package/AbstractSqlDriver.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ALIAS_REPLACEMENT_RE, DatabaseDriver, EntityManagerType, getLoadingStrategy, getOnConflictFields, getOnConflictReturningFields, helper, isRaw, LoadStrategy, parseJsonSafe, PolymorphicRef, QueryFlag, QueryHelper, QueryOrder, raw, RawQueryFragment, ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
1
|
+
import { ALIAS_REPLACEMENT_RE, DatabaseDriver, DateType, EntityManagerType, getLoadingStrategy, getOnConflictFields, getOnConflictReturningFields, helper, isRaw, LoadStrategy, parseJsonSafe, PolymorphicRef, QueryFlag, QueryHelper, QueryOrder, raw, RawQueryFragment, ReferenceKind, Utils, } from '@mikro-orm/core';
|
|
2
2
|
import { QueryBuilder } from './query/QueryBuilder.js';
|
|
3
3
|
import { JoinType, QueryType } from './query/enums.js';
|
|
4
4
|
import { SqlEntityManager } from './SqlEntityManager.js';
|
|
@@ -612,6 +612,11 @@ export class AbstractSqlDriver extends DatabaseDriver {
|
|
|
612
612
|
relationPojo[prop.name] = value;
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
|
+
else if (prop.customType instanceof DateType) {
|
|
616
|
+
// tedious returns DATE columns as `Date`, map them to the string the entity holds, so the snapshot matches it
|
|
617
|
+
const value = row[keys[0]];
|
|
618
|
+
relationPojo[prop.name] = (value instanceof Date ? this.platform.convertDateToJSValue(value) : value);
|
|
619
|
+
}
|
|
615
620
|
else {
|
|
616
621
|
relationPojo[prop.name] = row[keys[0]];
|
|
617
622
|
if (prop.kind === ReferenceKind.EMBEDDED && (prop.object || meta.embeddable)) {
|
|
@@ -231,8 +231,9 @@ export class BasePostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
231
231
|
return ['begin'];
|
|
232
232
|
}
|
|
233
233
|
marshallArray(values) {
|
|
234
|
-
|
|
235
|
-
|
|
234
|
+
// Quote what Postgres would read differently unquoted: empty, `NULL`, delimiters and surrounding whitespace.
|
|
235
|
+
const quote = (v) => v === '' || /^null$/i.test(v) || /["{},\\]|^\s|\s$/.test(v) ? `"${v.replace(/["\\]/g, '\\$&')}"` : v;
|
|
236
|
+
return `{${values.map(v => (v === null ? 'NULL' : quote('' + v))).join(',')}}`;
|
|
236
237
|
}
|
|
237
238
|
/* v8 ignore next */
|
|
238
239
|
unmarshallArray(value) {
|
|
@@ -1279,9 +1279,11 @@ export class PostgreSqlSchemaHelper extends SchemaHelper {
|
|
|
1279
1279
|
const name = (schemaName && schemaName !== this.platform.getDefaultSchemaName() ? schemaName + '.' : '') + tableName;
|
|
1280
1280
|
if (column.autoincrement) {
|
|
1281
1281
|
const seqName = this.platform.getIndexName(tableName, [column.name], 'sequence');
|
|
1282
|
+
// the regclass text needs the quoted name too, otherwise postgres folds a mixed case name to lower case
|
|
1283
|
+
const seq = this.platform.quoteValue(this.quote(seqName));
|
|
1282
1284
|
ret.push(`create sequence if not exists ${this.quote(seqName)}`);
|
|
1283
|
-
ret.push(`select setval(
|
|
1284
|
-
ret.push(`alter table ${this.quote(name)} alter column ${this.quote(column.name)} set default nextval(
|
|
1285
|
+
ret.push(`select setval(${seq}, (select max(${this.quote(column.name)}) from ${this.quote(name)}))`);
|
|
1286
|
+
ret.push(`alter table ${this.quote(name)} alter column ${this.quote(column.name)} set default nextval(${seq})`);
|
|
1285
1287
|
}
|
|
1286
1288
|
return ret;
|
|
1287
1289
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/sql",
|
|
3
|
-
"version": "7.2.
|
|
3
|
+
"version": "7.2.11-dev.0",
|
|
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",
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"kysely": "0.29.9"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@mikro-orm/core": "^7.2.
|
|
53
|
+
"@mikro-orm/core": "^7.2.10"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
|
-
"@mikro-orm/core": "7.2.
|
|
56
|
+
"@mikro-orm/core": "7.2.11-dev.0"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|
|
59
59
|
"node": ">= 22.17.0"
|