@mikro-orm/postgresql 6.3.5-dev.0 → 6.3.5-dev.10
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/PostgreSqlPlatform.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { type IPostgresInterval } from 'postgres-interval';
|
|
2
|
-
import { type EntityProperty, Type, type SimpleColumnMeta } from '@mikro-orm/core';
|
|
2
|
+
import { type EntityProperty, Type, type SimpleColumnMeta, type Configuration } from '@mikro-orm/core';
|
|
3
3
|
import { AbstractSqlPlatform, type IndexDef } from '@mikro-orm/knex';
|
|
4
4
|
import { PostgreSqlSchemaHelper } from './PostgreSqlSchemaHelper';
|
|
5
5
|
import { PostgreSqlExceptionConverter } from './PostgreSqlExceptionConverter';
|
|
6
6
|
export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
7
7
|
protected readonly schemaHelper: PostgreSqlSchemaHelper;
|
|
8
8
|
protected readonly exceptionConverter: PostgreSqlExceptionConverter;
|
|
9
|
+
setConfig(config: Configuration): void;
|
|
9
10
|
usesReturningStatement(): boolean;
|
|
10
11
|
usesCascadeStatement(): boolean;
|
|
11
12
|
supportsNativeEnums(): boolean;
|
|
@@ -67,6 +68,9 @@ export declare class PostgreSqlPlatform extends AbstractSqlPlatform {
|
|
|
67
68
|
getJsonIndexDefinition(index: IndexDef): string[];
|
|
68
69
|
quoteIdentifier(id: string, quote?: string): string;
|
|
69
70
|
quoteValue(value: any): string;
|
|
71
|
+
private pad;
|
|
72
|
+
/** @internal */
|
|
73
|
+
formatDate(date: Date): string;
|
|
70
74
|
indexForeignKeys(): boolean;
|
|
71
75
|
getDefaultMappedType(type: string): Type<unknown>;
|
|
72
76
|
supportsSchemas(): boolean;
|
package/PostgreSqlPlatform.js
CHANGED
|
@@ -15,6 +15,12 @@ const FullTextType_1 = require("./types/FullTextType");
|
|
|
15
15
|
class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
16
16
|
schemaHelper = new PostgreSqlSchemaHelper_1.PostgreSqlSchemaHelper(this);
|
|
17
17
|
exceptionConverter = new PostgreSqlExceptionConverter_1.PostgreSqlExceptionConverter();
|
|
18
|
+
setConfig(config) {
|
|
19
|
+
if (config.get('forceUtcTimezone') == null) {
|
|
20
|
+
config.set('forceUtcTimezone', true);
|
|
21
|
+
}
|
|
22
|
+
super.setConfig(config);
|
|
23
|
+
}
|
|
18
24
|
usesReturningStatement() {
|
|
19
25
|
return true;
|
|
20
26
|
}
|
|
@@ -221,13 +227,46 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
221
227
|
return pg_1.Client.prototype.escapeLiteral(value);
|
|
222
228
|
}
|
|
223
229
|
if (value instanceof Date) {
|
|
224
|
-
return `'${
|
|
230
|
+
return `'${this.formatDate(value)}'`;
|
|
225
231
|
}
|
|
226
232
|
if (ArrayBuffer.isView(value)) {
|
|
227
233
|
return `E'\\\\x${value.toString('hex')}'`;
|
|
228
234
|
}
|
|
229
235
|
return super.quoteValue(value);
|
|
230
236
|
}
|
|
237
|
+
pad(number, digits) {
|
|
238
|
+
return String(number).padStart(digits, '0');
|
|
239
|
+
}
|
|
240
|
+
/** @internal */
|
|
241
|
+
formatDate(date) {
|
|
242
|
+
if (this.timezone === 'Z') {
|
|
243
|
+
return date.toISOString();
|
|
244
|
+
}
|
|
245
|
+
let offset = -date.getTimezoneOffset();
|
|
246
|
+
let year = date.getFullYear();
|
|
247
|
+
const isBCYear = year < 1;
|
|
248
|
+
/* istanbul ignore next */
|
|
249
|
+
if (isBCYear) {
|
|
250
|
+
year = Math.abs(year) + 1;
|
|
251
|
+
}
|
|
252
|
+
const datePart = `${this.pad(year, 4)}-${this.pad(date.getMonth() + 1, 2)}-${this.pad(date.getDate(), 2)}`;
|
|
253
|
+
const timePart = `${this.pad(date.getHours(), 2)}:${this.pad(date.getMinutes(), 2)}:${this.pad(date.getSeconds(), 2)}.${this.pad(date.getMilliseconds(), 3)}`;
|
|
254
|
+
let ret = `${datePart}T${timePart}`;
|
|
255
|
+
/* istanbul ignore if */
|
|
256
|
+
if (offset < 0) {
|
|
257
|
+
ret += '-';
|
|
258
|
+
offset *= -1;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
ret += '+';
|
|
262
|
+
}
|
|
263
|
+
ret += this.pad(Math.floor(offset / 60), 2) + ':' + this.pad(offset % 60, 2);
|
|
264
|
+
/* istanbul ignore next */
|
|
265
|
+
if (isBCYear) {
|
|
266
|
+
ret += ' BC';
|
|
267
|
+
}
|
|
268
|
+
return ret;
|
|
269
|
+
}
|
|
231
270
|
indexForeignKeys() {
|
|
232
271
|
return false;
|
|
233
272
|
}
|
|
@@ -314,6 +353,7 @@ class PostgreSqlPlatform extends knex_1.AbstractSqlPlatform {
|
|
|
314
353
|
return new Date(value);
|
|
315
354
|
}
|
|
316
355
|
const parsed = (0, postgres_date_1.default)(value);
|
|
356
|
+
/* istanbul ignore next */
|
|
317
357
|
if (parsed === null) {
|
|
318
358
|
return value;
|
|
319
359
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/postgresql",
|
|
3
|
-
"version": "6.3.5-dev.
|
|
3
|
+
"version": "6.3.5-dev.10",
|
|
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
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@mikro-orm/knex": "6.3.5-dev.
|
|
61
|
+
"@mikro-orm/knex": "6.3.5-dev.10",
|
|
62
62
|
"pg": "8.12.0",
|
|
63
63
|
"postgres-array": "3.0.2",
|
|
64
64
|
"postgres-date": "2.1.0",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
"@mikro-orm/core": "^6.3.4"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@mikro-orm/core": "6.3.5-dev.
|
|
71
|
+
"@mikro-orm/core": "6.3.5-dev.10"
|
|
72
72
|
}
|
|
73
73
|
}
|