@spinajs/orm-postgres 2.0.528

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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAqC,oBAAoB,EAAE,iBAAiB,EAAE,cAAc,EAAE,mBAAmB,EAAE,mBAAmB,EAAmB,YAAY,EAAsR,MAAM,cAAc,CAAC;AACngB,OAAO,EAAE,SAAS,EAAqH,MAAM,kBAAkB,CAAC;AAChK,OAAO,EAAE,MAAM,IAAI,CAAC;AAKpB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAEhC,MAAM,WAAW,2BAA4B,SAAQ,mBAAmB;IACtE,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC;CAC3B;AASD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,qBAAa,4BAA6B,SAAQ,oBAAoB;IAC7D,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,MAAM,EAAE;;;;MAqBxC;CACF;AAED,qBAEa,iBAAkB,SAAQ,SAAS;IAC9C,SAAS,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC;IAExB;;;OAGG;IACH,SAAgB,wBAAwB,EAAE,cAAc,EAAE,CAA6E;IAEvI;;;;;OAKG;IACH,SAAgB,mBAAmB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAIpE;IAEK,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,CAInF;IAED,SAAS,CAAC,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,OA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 +1,380 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
14
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
15
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
16
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
17
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
18
+ };
19
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
20
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
21
+ };
22
+ var __importDefault = (this && this.__importDefault) || function (mod) {
23
+ return (mod && mod.__esModule) ? mod : { "default": mod };
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.PostgresOrmDriver = exports.PostgresServerResponseMapper = void 0;
27
+ exports.toPositionalParameters = toPositionalParameters;
28
+ /* eslint-disable @typescript-eslint/no-explicit-any */
29
+ const di_1 = require("@spinajs/di");
30
+ const orm_1 = require("@spinajs/orm");
31
+ const orm_sql_1 = require("@spinajs/orm-sql");
32
+ const pg_1 = __importDefault(require("pg"));
33
+ const compilers_js_1 = require("./compilers.js");
34
+ const statements_js_1 = require("./statements.js");
35
+ __exportStar(require("./compilers.js"), exports);
36
+ __exportStar(require("./statements.js"), exports);
37
+ /**
38
+ * SQLSTATE classes that mean the transport died rather than the statement being wrong.
39
+ * 08xxx is the connection-exception class; 57P01–57P03 are the server telling us it is
40
+ * going away ( admin shutdown, crash shutdown, cannot connect now ).
41
+ */
42
+ const PG_RETRYABLE_CODES = new Set(['08000', '08001', '08003', '08004', '08006', '08007', '57P01', '57P02', '57P03']);
43
+ /**
44
+ * Rewrites the `?` placeholders every compiler emits into the `$1..$n` positional
45
+ * parameters the pg protocol requires. Same brute-force walk the MSSQL driver does for
46
+ * its `@p` parameters — the compilers bind every user value, so a literal `?` does not
47
+ * appear in generated SQL outside of a placeholder position.
48
+ */
49
+ function toPositionalParameters(stmt) {
50
+ let i = 0;
51
+ return stmt.replace(/\?/g, () => `$${++i}`);
52
+ }
53
+ class PostgresServerResponseMapper extends orm_1.ServerResponseMapper {
54
+ read(data, pkNames) {
55
+ // Upserts resolve with their RETURNING rows directly.
56
+ if (Array.isArray(data)) {
57
+ const last = data.length !== 0 ? data[data.length - 1] : undefined;
58
+ const key = pkNames && pkNames.length === 1 && last ? last[pkNames[0]] : 0;
59
+ return {
60
+ RowsAffected: data.length,
61
+ // A uuid / assigned key is not a number and has no identity semantics.
62
+ LastInsertId: typeof key === 'number' ? key : 0,
63
+ Returning: data,
64
+ };
65
+ }
66
+ // A RETURNING insert arrives normalized by executeOnDb, carrying its rows; a plain
67
+ // run carries none. Passing the rows through is what lets the caller read generated keys.
68
+ return {
69
+ RowsAffected: data?.RowsAffected ?? 0,
70
+ LastInsertId: data?.LastInsertId ?? 0,
71
+ Returning: Array.isArray(data?.Returning) ? data.Returning : [],
72
+ };
73
+ }
74
+ }
75
+ exports.PostgresServerResponseMapper = PostgresServerResponseMapper;
76
+ let PostgresOrmDriver = class PostgresOrmDriver extends orm_sql_1.SqlDriver {
77
+ constructor() {
78
+ super(...arguments);
79
+ /**
80
+ * Postgres parses all four standard levels; READ UNCOMMITTED is accepted and behaves as
81
+ * READ COMMITTED, which is the standard-permitted upgrade, so it is not refused here.
82
+ */
83
+ this.SupportedIsolationLevels = ['READ UNCOMMITTED', 'READ COMMITTED', 'REPEATABLE READ', 'SERIALIZABLE'];
84
+ /**
85
+ * pg hands NUMERIC/DECIMAL and BIGINT back as STRINGS: both can exceed 2^53, where a
86
+ * float loses exactly the precision those types exist to keep, so node-postgres refuses
87
+ * to guess. No converter along the way changes that, so the RESPONSE schema has to say
88
+ * the same thing as the runtime. Reads only — on the request side these stay numbers.
89
+ */
90
+ this.ResponseSchemaTypes = {
91
+ decimal: { type: 'string' },
92
+ numeric: { type: 'string' },
93
+ bigint: { type: 'string' },
94
+ };
95
+ }
96
+ executeOnDb(stmt, params, context) {
97
+ // Reads and writes are both retried: `withReconnect` only re-runs on transport
98
+ // failures, where the statement provably never reached the server.
99
+ return this.withReconnect(() => this._executeOnDbOnce(stmt, params, context));
100
+ }
101
+ isRetryableError(err) {
102
+ // Inside a transaction the connection carried uncommitted state. Reconnecting and
103
+ // replaying one statement would silently apply it OUTSIDE the transaction.
104
+ if (this.TransactionStorage.getStore()) {
105
+ return false;
106
+ }
107
+ if (super.isRetryableError(err)) {
108
+ return true;
109
+ }
110
+ let current = err;
111
+ let depth = 0;
112
+ while (current && depth < 5) {
113
+ if (typeof current.code === 'string' && PG_RETRYABLE_CODES.has(current.code)) {
114
+ return true;
115
+ }
116
+ current = current.inner ?? current.cause;
117
+ depth++;
118
+ }
119
+ return false;
120
+ }
121
+ async _executeOnDbOnce(stmt, params, context) {
122
+ const finalQuery = toPositionalParameters(stmt);
123
+ // The context comes from the base driver; only this driver's `_begin` ever populates
124
+ // it, and it always puts a PoolClient in.
125
+ const txContext = this.TransactionStorage.getStore();
126
+ try {
127
+ let result;
128
+ if (txContext?.connection) {
129
+ // A transaction owns its client for its whole lifetime — statements must never
130
+ // land on another pooled connection.
131
+ result = await txContext.connection.query(finalQuery, params);
132
+ }
133
+ else {
134
+ // Taking the client explicitly, instead of letting `Pool.query` do it out of
135
+ // sight, is what makes `orm_pool_acquire_seconds` a real number instead of zero.
136
+ const acquireStart = process.hrtime.bigint();
137
+ const client = await this.Pool.connect();
138
+ this.observeAcquireSeconds(Number(process.hrtime.bigint() - acquireStart) / 1e9);
139
+ try {
140
+ result = await client.query(finalQuery, params);
141
+ }
142
+ finally {
143
+ client.release();
144
+ }
145
+ }
146
+ switch (context) {
147
+ case orm_1.QueryContext.Update:
148
+ case orm_1.QueryContext.Delete:
149
+ return {
150
+ RowsAffected: result.rowCount ?? 0,
151
+ };
152
+ case orm_1.QueryContext.Insert:
153
+ case orm_1.QueryContext.Upsert:
154
+ case orm_1.QueryContext.InsertReturning:
155
+ // Postgres has no LAST_INSERT_ID counter at all — generated keys travel in the
156
+ // RETURNING rows, which insertReturning: true makes the ORM ask for.
157
+ return {
158
+ RowsAffected: result.rowCount ?? result.rows.length,
159
+ LastInsertId: 0,
160
+ Returning: result.rows ?? [],
161
+ };
162
+ default:
163
+ return result.rows;
164
+ }
165
+ }
166
+ catch (err) {
167
+ throw new orm_1.OrmException(`Error executing orm command `, {
168
+ Host: this.Options.Host,
169
+ User: this.Options.User,
170
+ Name: this.Options.Name,
171
+ }, stmt, params, err);
172
+ }
173
+ }
174
+ supportedFeatures() {
175
+ return {
176
+ // No CREATE EVENT and no shared trigger dialect: scheduling on postgres is
177
+ // pg_cron / external, and claiming support would only move the failure further
178
+ // from its cause.
179
+ events: false,
180
+ insertReturning: true,
181
+ // With RETURNING every key comes back per row; the LAST_INSERT_ID batch walk is
182
+ // MySQL's workaround for not having it.
183
+ insertIdIsFirstOfBatch: false,
184
+ };
185
+ }
186
+ resolve() {
187
+ super.resolve();
188
+ this.Container.register(compilers_js_1.PostgresTableExistsCompiler).as(orm_1.TableExistsCompiler);
189
+ this.Container.register(PostgresServerResponseMapper).as(orm_1.ServerResponseMapper);
190
+ /**
191
+ * The postgres dialect. Every class that would otherwise arrive from the shared
192
+ * `orm-sql` layer speaking MySQL is either replaced with the postgres spelling or —
193
+ * when the shared SQL happens to be valid postgres — claimed explicitly, so nothing
194
+ * dialect-specific is inherited by accident.
195
+ */
196
+ this.Container.register(statements_js_1.DoubleQuoteIdentifierQuoter).as(orm_1.IdentifierQuoter);
197
+ this.Container.register(compilers_js_1.PostgresOnDuplicateQueryCompiler).as(orm_1.OnDuplicateQueryCompiler);
198
+ this.Container.register(compilers_js_1.PostgresInsertQueryCompiler).as(orm_1.InsertQueryCompiler);
199
+ this.Container.register(compilers_js_1.PostgresColumnQueryCompiler).as(orm_1.ColumnQueryCompiler);
200
+ this.Container.register(compilers_js_1.PostgresAlterColumnQueryCompiler).as(orm_1.AlterColumnQueryCompiler);
201
+ this.Container.register(compilers_js_1.PostgresLimitQueryCompiler).as(orm_1.LimitQueryCompiler);
202
+ this.Container.register(compilers_js_1.PostgresCreateDatabaseQueryCompiler).as(orm_1.CreateDatabaseCompiler);
203
+ this.Container.register(compilers_js_1.PostgresDefaultValueBuilder).as(orm_1.DefaultValueBuilder);
204
+ // Shared implementations that happen to be valid postgres, claimed explicitly.
205
+ // DROP DATABASE IF EXISTS is among them: with this driver's quoter injected the
206
+ // shared compiler already emits exactly the postgres statement.
207
+ // `CREATE TABLE ... LIKE`, `CREATE EVENT`, MySQL trigger syntax and `CHANGE COLUMN`
208
+ // are NOT among them and stay unregistered: those features fail with a DI error
209
+ // naming the abstraction instead of reaching postgres as MySQL syntax.
210
+ this.Container.register(orm_sql_1.SqlDropDatabaseQueryCompiler).as(orm_1.DropDatabaseCompiler);
211
+ this.Container.register(orm_sql_1.SqlTruncateTableQueryCompiler).as(orm_1.TruncateTableQueryCompiler);
212
+ this.Container.register(orm_sql_1.SqlWithRecursiveCompiler).as(orm_1.RecursiveQueryCompiler);
213
+ this.Container.register(orm_sql_1.SqlAlterTableQueryCompiler).as(orm_1.AlterTableQueryCompiler);
214
+ }
215
+ /** pg.Pool publishes its bookkeeping — no private-field spelunking needed here. */
216
+ poolMetrics() {
217
+ return {
218
+ Size: this.Pool?.totalCount ?? 0,
219
+ InUse: Math.max((this.Pool?.totalCount ?? 0) - (this.Pool?.idleCount ?? 0), 0),
220
+ Waiting: this.Pool?.waitingCount ?? 0,
221
+ };
222
+ }
223
+ async ping() {
224
+ try {
225
+ // deliberately bypasses `withReconnect` — a health probe that reconnects on its own
226
+ // would turn one dead connection into a reconnect storm on every tick.
227
+ await this._executeOnDbOnce('SELECT 1', [], orm_1.QueryContext.Select);
228
+ return true;
229
+ }
230
+ catch {
231
+ return false;
232
+ }
233
+ }
234
+ async connect() {
235
+ const pool = this.resolvedPoolOptions();
236
+ this.Pool = new pg_1.default.Pool({
237
+ host: this.Options.Host,
238
+ user: this.Options.User,
239
+ password: this.Options.Password,
240
+ port: this.Options.Port,
241
+ database: this.Options.Database,
242
+ max: pool.Max,
243
+ min: pool.Min,
244
+ idleTimeoutMillis: pool.IdleTimeout,
245
+ connectionTimeoutMillis: pool.AcquireTimeout,
246
+ });
247
+ // An idle client's connection can die between checkouts; without a listener pg emits
248
+ // 'error' on the pool and an unhandled 'error' event kills the process.
249
+ this.Pool.on('error', (err) => {
250
+ this.Log?.warn(`postgres pool connection error for ${this.Options.Name}: ${err.message}`);
251
+ });
252
+ try {
253
+ // Test the pool, and pin the schema when one is configured: search_path is a
254
+ // session setting, so it has to be set per connection as the pool opens them.
255
+ const client = await this.Pool.connect();
256
+ client.release();
257
+ const schema = this.Options.Options?.Schema;
258
+ if (schema) {
259
+ this.Pool.on('connect', (c) => {
260
+ c.query(`SET search_path TO ${(0, statements_js_1.pgEscapeIdentifier)(schema)}`).catch((err) => {
261
+ this.Log?.warn(`could not set search_path to ${schema} for ${this.Options.Name}: ${err.message}`);
262
+ });
263
+ });
264
+ // the test client above predates the listener
265
+ await this.executeOnDb(`SET search_path TO ${(0, statements_js_1.pgEscapeIdentifier)(schema)}`, [], orm_1.QueryContext.Schema);
266
+ }
267
+ this.setState(orm_1.ConnectionState.Connected);
268
+ return this;
269
+ }
270
+ catch (err) {
271
+ await this.Pool.end().catch(() => undefined);
272
+ this.Pool = null;
273
+ throw err;
274
+ }
275
+ }
276
+ async disconnect() {
277
+ this.stopHealthCheck();
278
+ this.setState(orm_1.ConnectionState.Disconnected);
279
+ if (this.Pool) {
280
+ await this.Pool.end();
281
+ this.Pool = null;
282
+ }
283
+ return this;
284
+ }
285
+ async tableInfo(name, schema) {
286
+ const dbSchema = schema ?? this.Options.Options?.Schema ?? 'public';
287
+ // ORDER BY ordinal_position is not decoration: column order is part of what a table
288
+ // descriptor means, and without it postgres is free to return rows in any order.
289
+ const tblInfo = (await this.executeOnDb(`SELECT column_name, data_type, udt_name, is_nullable, column_default, is_identity
290
+ FROM information_schema.columns
291
+ WHERE table_name = ? AND table_schema = ?
292
+ ORDER BY ordinal_position`, [name, dbSchema], orm_1.QueryContext.Select));
293
+ if (!tblInfo || !Array.isArray(tblInfo) || tblInfo.length === 0) {
294
+ return null;
295
+ }
296
+ const constraints = (await this.executeOnDb(`SELECT kcu.column_name, tc.constraint_type
297
+ FROM information_schema.table_constraints tc
298
+ JOIN information_schema.key_column_usage kcu
299
+ ON kcu.constraint_name = tc.constraint_name AND kcu.table_schema = tc.table_schema
300
+ WHERE tc.table_name = ? AND tc.table_schema = ?`, [name, dbSchema], orm_1.QueryContext.Select));
301
+ return tblInfo.map((r) => {
302
+ const isPrimary = constraints.find((c) => c.constraint_type === 'PRIMARY KEY' && c.column_name === r.column_name) !== undefined;
303
+ const isUnique = constraints.find((c) => c.constraint_type === 'UNIQUE' && c.column_name === r.column_name) !== undefined;
304
+ return {
305
+ // udt_name is the concrete type ( int4, varchar, numeric ); data_type spells the
306
+ // standard name ( "character varying" ) that nothing downstream recognises.
307
+ Type: r.udt_name,
308
+ MaxLength: -1,
309
+ Comment: '',
310
+ DefaultValue: r.column_default,
311
+ NativeType: r.udt_name,
312
+ Unsigned: false,
313
+ Nullable: r.is_nullable === 'YES',
314
+ PrimaryKey: isPrimary,
315
+ Uuid: false,
316
+ Ignore: false,
317
+ IsForeignKey: false,
318
+ Virtual: false,
319
+ ForeignKeyDescription: null,
320
+ // identity is postgres 10+; nextval() in the default is the legacy SERIAL spelling
321
+ AutoIncrement: r.is_identity === 'YES' || (r.column_default ?? '').startsWith('nextval('),
322
+ Name: r.column_name,
323
+ Aggregate: false,
324
+ Converter: null,
325
+ Schema: dbSchema,
326
+ Unique: isUnique,
327
+ };
328
+ });
329
+ }
330
+ /**
331
+ * Pulls the pooled client out of a transaction context. The base class only ever hands
332
+ * us contexts this driver's own `_begin` produced.
333
+ */
334
+ txConnection(ctx) {
335
+ return ctx.connection;
336
+ }
337
+ async _begin(options) {
338
+ const connection = await this.Pool.connect();
339
+ try {
340
+ await connection.query('BEGIN');
341
+ if (options?.isolation) {
342
+ // Unlike MySQL, postgres sets the level INSIDE the transaction. The level is a
343
+ // fixed, validated enum — never caller-supplied free text.
344
+ await connection.query(`SET TRANSACTION ISOLATION LEVEL ${options.isolation}`);
345
+ }
346
+ return { connection, depth: 0 };
347
+ }
348
+ catch (err) {
349
+ connection.release();
350
+ throw err;
351
+ }
352
+ }
353
+ async _commit(ctx) {
354
+ await this.txConnection(ctx).query('COMMIT');
355
+ }
356
+ async _rollback(ctx) {
357
+ await this.txConnection(ctx).query('ROLLBACK');
358
+ }
359
+ // savepoint names cannot be bound parameters, so they are inlined through this driver's
360
+ // own identifier escaper rather than passed as `?`
361
+ async _savepoint(ctx, name) {
362
+ await this.txConnection(ctx).query(`SAVEPOINT ${(0, statements_js_1.pgEscapeIdentifier)(name)}`);
363
+ }
364
+ async _releaseSavepoint(ctx, name) {
365
+ await this.txConnection(ctx).query(`RELEASE SAVEPOINT ${(0, statements_js_1.pgEscapeIdentifier)(name)}`);
366
+ }
367
+ async _rollbackToSavepoint(ctx, name) {
368
+ await this.txConnection(ctx).query(`ROLLBACK TO SAVEPOINT ${(0, statements_js_1.pgEscapeIdentifier)(name)}`);
369
+ }
370
+ _dispose(ctx) {
371
+ this.txConnection(ctx).release();
372
+ return Promise.resolve();
373
+ }
374
+ };
375
+ exports.PostgresOrmDriver = PostgresOrmDriver;
376
+ exports.PostgresOrmDriver = PostgresOrmDriver = __decorate([
377
+ (0, di_1.Injectable)('orm-driver-postgres'),
378
+ (0, di_1.NewInstance)()
379
+ ], PostgresOrmDriver);
380
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,oCAAsD;AACtD,sCAAmgB;AACngB,8CAAgK;AAChK,4CAAoB;AACpB,iDAAyR;AACzR,mDAAkF;AAGlF,iDAA+B;AAC/B,kDAAgC;AAMhC;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;AAEtH;;;;;GAKG;AACH,gCAAuC,IAAY;IACjD,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;AAC9C,CAAC;AAED,kCAA0C,SAAQ,0BAAoB;IAC7D,IAAI,CAAC,IAAS,EAAE,OAAkB;QACvC,sDAAsD;QACtD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACnE,MAAM,GAAG,GAAG,OAAO,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAE3E,OAAO;gBACL,Y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AES,KAAK,CAAC,iBAAiB,CAAC,GAAwB,EAAE,IAAY;QACtE,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,qBAAqB,IAAA,kCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACtF,CAAC;IAES,KAAK,CAAC,oBAAoB,CAAC,GAAwB,EAAE,IAAY;QACzE,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,yBAAyB,IAAA,kCAAkB,EAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1F,CAAC;IAES,QAAQ,CAAC,GAAwB;QACzC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;QACjC,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;IAC3B,CAAC;CACF,CAAA;;4BA9VY,iBAAiB;IAF7B,IAAA,eAAU,EAAC,qBAAqB,CAAC;IACjC,IAAA,gBAAW,GAAE;GACD,iBAAiB,CA8V7B"}
@@ -0,0 +1 @@
1
+ {"type":"commonjs"}
@@ -0,0 +1,17 @@
1
+ import { IdentifierQuoter } from '@spinajs/orm';
2
+ /**
3
+ * PostgreSQL quotes identifiers with the ANSI double quote and escapes an embedded `"` by
4
+ * doubling it. The shared `orm-sql` helper emits backticks, which PostgreSQL reads as an
5
+ * operator error, so the driver carries its own escaper for its internal SQL ( savepoint
6
+ * names, schema probes ) the same way MSSQL does.
7
+ */
8
+ export declare function pgEscapeIdentifier(name: string): string;
9
+ /**
10
+ * The ANSI double quote — PostgreSQL's identifier quoting. Registered by the postgres
11
+ * driver as its {@link IdentifierQuoter}, never inherited: MySQL rejects `"` as an
12
+ * identifier quote unless ANSI_QUOTES is on, so nothing here is portable either way.
13
+ */
14
+ export declare class DoubleQuoteIdentifierQuoter extends IdentifierQuoter {
15
+ quote(name: string): string;
16
+ }
17
+ //# sourceMappingURL=statements.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statements.d.ts","sourceRoot":"","sources":["../../src/statements.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAEhD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED;;;;GAIG;AACH,qBACa,2BAA4B,SAAQ,gBAAgB;IACxD,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEjC;CACF"}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.DoubleQuoteIdentifierQuoter = void 0;
10
+ exports.pgEscapeIdentifier = pgEscapeIdentifier;
11
+ const di_1 = require("@spinajs/di");
12
+ const orm_1 = require("@spinajs/orm");
13
+ /**
14
+ * PostgreSQL quotes identifiers with the ANSI double quote and escapes an embedded `"` by
15
+ * doubling it. The shared `orm-sql` helper emits backticks, which PostgreSQL reads as an
16
+ * operator error, so the driver carries its own escaper for its internal SQL ( savepoint
17
+ * names, schema probes ) the same way MSSQL does.
18
+ */
19
+ function pgEscapeIdentifier(name) {
20
+ return '"' + String(name).replace(/"/g, '""') + '"';
21
+ }
22
+ /**
23
+ * The ANSI double quote — PostgreSQL's identifier quoting. Registered by the postgres
24
+ * driver as its {@link IdentifierQuoter}, never inherited: MySQL rejects `"` as an
25
+ * identifier quote unless ANSI_QUOTES is on, so nothing here is portable either way.
26
+ */
27
+ let DoubleQuoteIdentifierQuoter = class DoubleQuoteIdentifierQuoter extends orm_1.IdentifierQuoter {
28
+ quote(name) {
29
+ return pgEscapeIdentifier(name);
30
+ }
31
+ };
32
+ exports.DoubleQuoteIdentifierQuoter = DoubleQuoteIdentifierQuoter;
33
+ exports.DoubleQuoteIdentifierQuoter = DoubleQuoteIdentifierQuoter = __decorate([
34
+ (0, di_1.NewInstance)()
35
+ ], DoubleQuoteIdentifierQuoter);
36
+ //# sourceMappingURL=statements.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statements.js","sourceRoot":"","sources":["../../src/statements.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,oCAA0C;AAC1C,sCAAgD;AAEhD;;;;;GAKG;AACH,4BAAmC,IAAY;IAC7C,OAAO,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,GAAG,CAAC;AACtD,CAAC;AAED;;;;GAIG;AAEI,IAAM,2BAA2B,GAAjC,MAAM,2BAA4B,SAAQ,sBAAgB;IACxD,KAAK,CAAC,IAAY;QACvB,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF,CAAA;;sCAJY,2BAA2B;IADvC,IAAA,gBAAW,GAAE;GACD,2BAA2B,CAIvC"}
@@ -0,0 +1,15 @@
1
+ /** One row of `information_schema.columns` — only the fields tableInfo() reads. */
2
+ export interface ITableColumnInfo {
3
+ column_name: string;
4
+ data_type: string;
5
+ udt_name: string;
6
+ is_nullable: 'YES' | 'NO';
7
+ column_default: string | null;
8
+ is_identity: 'YES' | 'NO';
9
+ }
10
+ /** One row of the constraint probe joining table_constraints and key_column_usage. */
11
+ export interface IConstraintInfo {
12
+ column_name: string;
13
+ constraint_type: 'PRIMARY KEY' | 'UNIQUE' | 'FOREIGN KEY' | 'CHECK';
14
+ }
15
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;IAC1B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,KAAK,GAAG,IAAI,CAAC;CAC3B;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,aAAa,GAAG,QAAQ,GAAG,aAAa,GAAG,OAAO,CAAC;CACrE"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,122 @@
1
+ import { Container, IContainer } from '@spinajs/di';
2
+ import { Log } from '@spinajs/log';
3
+ import { ICompilerOutput, OnDuplicateQueryBuilder, InsertQueryBuilder, TableExistsCompiler, TableExistsQueryBuilder, LimitQueryCompiler, LimitBuilder, CreateDatabaseCompiler, CreateDatabaseQueryBuilder, IdentifierQuoter } from '@spinajs/orm';
4
+ import { SqlInsertQueryCompiler, SqlColumnQueryCompiler, SqlAlterColumnQueryCompiler, SqlOnDuplicateQueryCompiler, SqlDefaultValueBuilder } from '@spinajs/orm-sql';
5
+ export declare class PostgresTableExistsCompiler implements TableExistsCompiler {
6
+ protected builder: TableExistsQueryBuilder;
7
+ constructor(builder: TableExistsQueryBuilder);
8
+ compile(): ICompilerOutput;
9
+ }
10
+ /**
11
+ * LIMIT / OFFSET the postgres way. The shared compiler emits MySQL's
12
+ * `LIMIT 18446744073709551615` for an offset without a limit — a literal larger than
13
+ * BIGINT, which postgres rejects outright. Postgres accepts a bare OFFSET, so the
14
+ * workaround is simply dropped.
15
+ */
16
+ export declare class PostgresLimitQueryCompiler extends LimitQueryCompiler {
17
+ protected _builder: LimitBuilder<unknown>;
18
+ constructor(builder: LimitBuilder<unknown>);
19
+ compile(): ICompilerOutput;
20
+ }
21
+ /**
22
+ * Upsert, spelled `ON CONFLICT (...) DO UPDATE`. MySQL's `ON DUPLICATE KEY UPDATE` and its
23
+ * `VALUES(col)` reference are both rejected by postgres; the row that failed to insert is
24
+ * reachable as `EXCLUDED` instead, which — like VALUES(col) — applies each conflicting
25
+ * row's own values in a multi row upsert and needs no bindings.
26
+ */
27
+ export declare class PostgresOnDuplicateQueryCompiler extends SqlOnDuplicateQueryCompiler {
28
+ constructor(builder: OnDuplicateQueryBuilder);
29
+ compile(): {
30
+ bindings: any[];
31
+ expression: string;
32
+ };
33
+ }
34
+ export declare class PostgresInsertQueryCompiler extends SqlInsertQueryCompiler {
35
+ constructor(container: IContainer, builder: InsertQueryBuilder);
36
+ compile(): {
37
+ bindings: any[];
38
+ expression: string;
39
+ };
40
+ /**
41
+ * An identity column rejects an explicit NULL — postgres wants the DEFAULT keyword where
42
+ * MySQL and SQLite read NULL as "assign the key".
43
+ */
44
+ protected autoIncrementPlaceholder(): string;
45
+ /**
46
+ * `INSERT IGNORE` is MySQL; the postgres spelling of "silently skip the conflicting row"
47
+ * is `ON CONFLICT DO NOTHING`, which comes AFTER the values. Skipped when an upsert
48
+ * clause is present — the ON CONFLICT compiler emits its own conflict handling and two
49
+ * such clauses are invalid SQL.
50
+ */
51
+ protected ignore(): string;
52
+ /**
53
+ * RETURNING on a plain INSERT. Skipped when an upsert clause is present — the ON CONFLICT
54
+ * compiler emits its own RETURNING and two would be invalid SQL.
55
+ */
56
+ protected returning(): string;
57
+ protected into(): string;
58
+ }
59
+ /**
60
+ * Column DDL in the postgres dialect. Differences from the shared (MySQL) compiler, each
61
+ * with the postgres answer:
62
+ *
63
+ * - AUTO_INCREMENT does not exist: an integer-family column renders as
64
+ * `GENERATED BY DEFAULT AS IDENTITY` ( BY DEFAULT, not ALWAYS, because the ORM's batch
65
+ * insert path may supply an explicit key for some rows of a batch ).
66
+ * - ENUM and SET are not inline types: both render as TEXT, an enum additionally carrying
67
+ * a CHECK constraint over its members. SET stays plain TEXT because the shared
68
+ * SqlSetConverter stores a comma-joined string and the LIKE-based InSet statement reads
69
+ * it back.
70
+ * - UNSIGNED, CHARACTER SET and inline COMMENT have no postgres spelling and are dropped;
71
+ * COLLATE is kept ( postgres collations are identifiers, so it is quoted ).
72
+ * - MySQL type names map to their postgres equivalents ( DATETIME → TIMESTAMP,
73
+ * DOUBLE → DOUBLE PRECISION, BLOB → BYTEA, JSON → JSONB ).
74
+ */
75
+ export declare class PostgresColumnQueryCompiler extends SqlColumnQueryCompiler {
76
+ compile(): ICompilerOutput;
77
+ /**
78
+ * The `DEFAULT ...` fragment of the column body, or '' when none is set — public because
79
+ * the ALTER COLUMN compiler rebuilds it into `ALTER COLUMN x SET DEFAULT ...`.
80
+ */
81
+ defaultExpression(): string;
82
+ /**
83
+ * The bare type, without constraints — public because the ALTER COLUMN compiler needs
84
+ * exactly this piece for `ALTER COLUMN x TYPE t`.
85
+ */
86
+ typeExpression(): string;
87
+ }
88
+ /**
89
+ * ALTER COLUMN, postgres style.
90
+ *
91
+ * MySQL's MODIFY restates the whole column in one clause; postgres alters each attribute
92
+ * with its own action, and — matching MODIFY's semantics, where any omitted attribute is
93
+ * dropped — an absent NOT NULL / DEFAULT drops the constraint rather than leaving it.
94
+ * The actions are comma-joined, so the parent compiler's `ALTER TABLE t ` prefix yields
95
+ * one valid multi-action statement.
96
+ */
97
+ export declare class PostgresAlterColumnQueryCompiler extends SqlAlterColumnQueryCompiler {
98
+ protected Log: Log;
99
+ protected _columnDefinition(): ICompilerOutput;
100
+ protected _add(definition: string): string | null;
101
+ protected _modify(_definition: string): string | null;
102
+ }
103
+ /**
104
+ * Postgres spells database DDL its own way: encoding is `ENCODING`, not CHARACTER SET,
105
+ * and CREATE DATABASE has no IF NOT EXISTS at all — existence has to be checked by the
106
+ * caller, so the flag is refused rather than silently dropped.
107
+ */
108
+ export declare class PostgresCreateDatabaseQueryCompiler extends CreateDatabaseCompiler {
109
+ protected container: Container;
110
+ protected builder: CreateDatabaseQueryBuilder;
111
+ Quoter: IdentifierQuoter;
112
+ constructor(container: Container, builder: CreateDatabaseQueryBuilder);
113
+ compile(): ICompilerOutput;
114
+ }
115
+ /**
116
+ * `CURRENT_DATE()` — with the parentheses the shared builder emits — is a syntax error in
117
+ * postgres: both CURRENT_DATE and CURRENT_TIMESTAMP are niladic keywords there.
118
+ */
119
+ export declare class PostgresDefaultValueBuilder<T> extends SqlDefaultValueBuilder<T> {
120
+ date(): T;
121
+ }
122
+ //# sourceMappingURL=compilers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compilers.d.ts","sourceRoot":"","sources":["../../src/compilers.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,SAAS,EAAE,UAAU,EAAc,MAAM,aAAa,CAAC;AAErF,OAAO,EAAU,GAAG,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAY,uBAAuB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,uBAAuB,EAAgB,kBAAkB,EAAE,YAAY,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,gBAAgB,EAA2C,MAAM,cAAc,CAAC;AACnT,OAAO,EAAE,sBAAsB,EAAE,sBAAsB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,sBAAsB,EAA0C,MAAM,kBAAkB,CAAC;AAG5M,qBACa,2BAA4B,YAAW,mBAAmB;IACzD,SAAS,CAAC,OAAO,EAAE,uBAAuB;IAAtD,YAAsB,OAAO,EAAE,uBAAuB,EAIrD;IAEM,OAAO,IAAI,eAAe,CAgBhC;CACF;AAED;;;;;GAKG;AACH,qBACa,0BAA2B,SAAQ,kBAAkB;IAChE,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,OAAO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