@nymphjs/driver-postgresql 1.0.0-beta.4 → 1.0.0-beta.41

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/CHANGELOG.md CHANGED
@@ -3,6 +3,164 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-beta.41](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.40...v1.0.0-beta.41) (2023-07-12)
7
+
8
+ ### Features
9
+
10
+ - remove synchronous database queries ([b579fb2](https://github.com/sciactive/nymphjs/commit/b579fb2eacd96cdd1b386a62c5c00cdbb2438f6e))
11
+
12
+ # [1.0.0-beta.40](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.39...v1.0.0-beta.40) (2023-07-10)
13
+
14
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
15
+
16
+ # [1.0.0-beta.39](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.38...v1.0.0-beta.39) (2023-07-09)
17
+
18
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
19
+
20
+ # [1.0.0-beta.38](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.37...v1.0.0-beta.38) (2023-07-09)
21
+
22
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
23
+
24
+ # [1.0.0-beta.37](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.36...v1.0.0-beta.37) (2023-07-09)
25
+
26
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
27
+
28
+ # [1.0.0-beta.36](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.35...v1.0.0-beta.36) (2023-07-09)
29
+
30
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
31
+
32
+ # [1.0.0-beta.35](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.34...v1.0.0-beta.35) (2023-06-14)
33
+
34
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
35
+
36
+ # [1.0.0-beta.34](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.33...v1.0.0-beta.34) (2023-05-13)
37
+
38
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
39
+
40
+ # [1.0.0-beta.33](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.32...v1.0.0-beta.33) (2023-05-13)
41
+
42
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
43
+
44
+ # [1.0.0-beta.32](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.31...v1.0.0-beta.32) (2023-05-13)
45
+
46
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
47
+
48
+ # [1.0.0-beta.31](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.30...v1.0.0-beta.31) (2023-05-12)
49
+
50
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
51
+
52
+ # [1.0.0-beta.30](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.29...v1.0.0-beta.30) (2023-05-12)
53
+
54
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
55
+
56
+ # [1.0.0-beta.29](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.28...v1.0.0-beta.29) (2023-05-08)
57
+
58
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
59
+
60
+ # [1.0.0-beta.28](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.27...v1.0.0-beta.28) (2023-05-05)
61
+
62
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
63
+
64
+ # [1.0.0-beta.27](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.26...v1.0.0-beta.27) (2023-05-04)
65
+
66
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
67
+
68
+ # [1.0.0-beta.26](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.25...v1.0.0-beta.26) (2023-05-04)
69
+
70
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
71
+
72
+ # [1.0.0-beta.25](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.24...v1.0.0-beta.25) (2023-05-04)
73
+
74
+ ### Bug Fixes
75
+
76
+ - don't create empty entities ([1d4d2e9](https://github.com/sciactive/nymphjs/commit/1d4d2e99af2e9cdc647bcf58ac34572836f41176))
77
+
78
+ # [1.0.0-beta.24](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.23...v1.0.0-beta.24) (2023-05-02)
79
+
80
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
81
+
82
+ # [1.0.0-beta.23](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.22...v1.0.0-beta.23) (2023-05-02)
83
+
84
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
85
+
86
+ # [1.0.0-beta.22](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.21...v1.0.0-beta.22) (2023-05-01)
87
+
88
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
89
+
90
+ # [1.0.0-beta.21](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.20...v1.0.0-beta.21) (2023-05-01)
91
+
92
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
93
+
94
+ # [1.0.0-beta.20](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.19...v1.0.0-beta.20) (2023-04-30)
95
+
96
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
97
+
98
+ # [1.0.0-beta.19](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.18...v1.0.0-beta.19) (2023-04-29)
99
+
100
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
101
+
102
+ # [1.0.0-beta.18](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.17...v1.0.0-beta.18) (2023-04-27)
103
+
104
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
105
+
106
+ # [1.0.0-beta.17](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.16...v1.0.0-beta.17) (2023-04-24)
107
+
108
+ ### Features
109
+
110
+ - use a long lived worker thread for synchronous mysql and postgres queries ([7e2bf84](https://github.com/sciactive/nymphjs/commit/7e2bf84a2d584d6906c31f44147025b793a05026))
111
+
112
+ # [1.0.0-beta.16](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.15...v1.0.0-beta.16) (2023-03-31)
113
+
114
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
115
+
116
+ # [1.0.0-beta.15](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.14...v1.0.0-beta.15) (2023-03-23)
117
+
118
+ ### Features
119
+
120
+ - add option to sort results by a property ([16384e7](https://github.com/sciactive/nymphjs/commit/16384e7bdab88abb55ccccabb06ac09f92fa8a03))
121
+
122
+ # [1.0.0-beta.14](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.13...v1.0.0-beta.14) (2023-03-17)
123
+
124
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
125
+
126
+ # [1.0.0-beta.13](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.12...v1.0.0-beta.13) (2023-03-16)
127
+
128
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
129
+
130
+ # [1.0.0-beta.12](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.11...v1.0.0-beta.12) (2023-03-04)
131
+
132
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
133
+
134
+ # [1.0.0-beta.11](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.10...v1.0.0-beta.11) (2023-02-27)
135
+
136
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
137
+
138
+ # [1.0.0-beta.10](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.9...v1.0.0-beta.10) (2023-01-19)
139
+
140
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
141
+
142
+ # [1.0.0-beta.9](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.8...v1.0.0-beta.9) (2023-01-09)
143
+
144
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
145
+
146
+ # [1.0.0-beta.8](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.7...v1.0.0-beta.8) (2023-01-09)
147
+
148
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
149
+
150
+ # [1.0.0-beta.7](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.6...v1.0.0-beta.7) (2023-01-05)
151
+
152
+ ### Bug Fixes
153
+
154
+ - sqlite transaction returns wrong instance of nymph if it has been cloned ([b278c76](https://github.com/sciactive/nymphjs/commit/b278c7633722cb1cca7a941187ae2f1ff8ebdc7b))
155
+
156
+ # [1.0.0-beta.6](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.5...v1.0.0-beta.6) (2023-01-05)
157
+
158
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
159
+
160
+ # [1.0.0-beta.5](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.4...v1.0.0-beta.5) (2022-11-24)
161
+
162
+ **Note:** Version bump only for package @nymphjs/driver-postgresql
163
+
6
164
  # [1.0.0-beta.4](https://github.com/sciactive/nymphjs/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2022-11-23)
7
165
 
8
166
  **Note:** Version bump only for package @nymphjs/driver-postgresql
@@ -19,6 +19,7 @@ export default class PostgreSQLDriver extends NymphDriver {
19
19
  static escape(input: string): string;
20
20
  static escapeValue(input: string): string;
21
21
  constructor(config: Partial<PostgreSQLDriverConfig>, link?: Pool, transaction?: PostgreSQLDriverTransaction);
22
+ clone(): PostgreSQLDriver;
22
23
  private getConnection;
23
24
  connect(): Promise<true>;
24
25
  disconnect(): Promise<false>;
@@ -27,12 +28,9 @@ export default class PostgreSQLDriver extends NymphDriver {
27
28
  private createTables;
28
29
  private translateQuery;
29
30
  private query;
30
- private querySync;
31
31
  private queryIter;
32
- private queryIterSync;
33
32
  private queryGet;
34
33
  private queryRun;
35
- private queryRunSync;
36
34
  commit(name: string): Promise<boolean>;
37
35
  deleteEntityByID(guid: string, className?: EntityConstructor | string | null): Promise<boolean>;
38
36
  deleteUID(name: string): Promise<boolean>;
@@ -41,9 +39,6 @@ export default class PostgreSQLDriver extends NymphDriver {
41
39
  protected performQuery(options: Options, formattedSelectors: FormattedSelector[], etype: string): {
42
40
  result: any;
43
41
  };
44
- protected performQuerySync(options: Options, formattedSelectors: FormattedSelector[], etype: string): {
45
- result: any;
46
- };
47
42
  getEntities<T extends EntityConstructor = EntityConstructor>(options: Options<T> & {
48
43
  return: 'count';
49
44
  }, ...selectors: Selector[]): Promise<number>;
@@ -51,13 +46,6 @@ export default class PostgreSQLDriver extends NymphDriver {
51
46
  return: 'guid';
52
47
  }, ...selectors: Selector[]): Promise<string[]>;
53
48
  getEntities<T extends EntityConstructor = EntityConstructor>(options?: Options<T>, ...selectors: Selector[]): Promise<ReturnType<T['factorySync']>[]>;
54
- protected getEntitiesSync<T extends EntityConstructor = EntityConstructor>(options: Options<T> & {
55
- return: 'count';
56
- }, ...selectors: Selector[]): number;
57
- protected getEntitiesSync<T extends EntityConstructor = EntityConstructor>(options: Options<T> & {
58
- return: 'guid';
59
- }, ...selectors: Selector[]): string[];
60
- protected getEntitiesSync<T extends EntityConstructor = EntityConstructor>(options?: Options<T>, ...selectors: Selector[]): ReturnType<T['factorySync']>[];
61
49
  getUID(name: string): Promise<number | null>;
62
50
  import(filename: string): Promise<boolean>;
63
51
  newUID(name: string): Promise<number>;
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const child_process_1 = __importDefault(require("child_process"));
7
6
  const pg_1 = require("pg");
8
7
  const pg_format_1 = __importDefault(require("pg-format"));
9
8
  const nymph_1 = require("@nymphjs/nymph");
@@ -41,6 +40,9 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
41
40
  this.connect();
42
41
  }
43
42
  }
43
+ clone() {
44
+ return new PostgreSQLDriver(this.config, this.link, this.transaction ?? undefined);
45
+ }
44
46
  getConnection() {
45
47
  if (this.transaction != null && this.transaction.connection != null) {
46
48
  return Promise.resolve(this.transaction.connection);
@@ -95,23 +97,23 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
95
97
  isConnected() {
96
98
  return this.connected;
97
99
  }
98
- createTables(etype = null) {
100
+ async createTables(etype = null) {
99
101
  if (etype != null) {
100
- this.queryRunSync(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} (
102
+ await this.queryRun(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} (
101
103
  "guid" BYTEA NOT NULL,
102
104
  "tags" TEXT[],
103
105
  "cdate" DOUBLE PRECISION NOT NULL,
104
106
  "mdate" DOUBLE PRECISION NOT NULL,
105
107
  PRIMARY KEY ("guid")
106
108
  ) WITH ( OIDS=FALSE );`);
107
- this.queryRunSync(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
108
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_cdate`)};`);
109
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_cdate`)} ON ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} USING btree ("cdate");`);
110
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_mdate`)};`);
111
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_mdate`)} ON ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} USING btree ("mdate");`);
112
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_tags`)};`);
113
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_tags`)} ON ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} USING gin ("tags");`);
114
- this.queryRunSync(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} (
109
+ await this.queryRun(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
110
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_cdate`)};`);
111
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_cdate`)} ON ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} USING btree ("cdate");`);
112
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_mdate`)};`);
113
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_mdate`)} ON ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} USING btree ("mdate");`);
114
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_tags`)};`);
115
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}_id_tags`)} ON ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} USING gin ("tags");`);
116
+ await this.queryRun(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} (
115
117
  "guid" BYTEA NOT NULL,
116
118
  "name" TEXT NOT NULL,
117
119
  "value" TEXT NOT NULL,
@@ -119,16 +121,16 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
119
121
  FOREIGN KEY ("guid")
120
122
  REFERENCES ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ("guid") MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE
121
123
  ) WITH ( OIDS=FALSE );`);
122
- this.queryRunSync(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
123
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid`)};`);
124
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("guid");`);
125
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_name`)};`);
126
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_name`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("name");`);
127
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__user`)};`);
128
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__user`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("guid") WHERE "name" = 'user'::text;`);
129
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__group`)};`);
130
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__group`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("guid") WHERE "name" = 'group'::text;`);
131
- this.queryRunSync(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} (
124
+ await this.queryRun(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
125
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid`)};`);
126
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("guid");`);
127
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_name`)};`);
128
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_name`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("name");`);
129
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__user`)};`);
130
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__user`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("guid") WHERE "name" = 'user'::text;`);
131
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__group`)};`);
132
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}_id_guid_name__group`)} ON ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} USING btree ("guid") WHERE "name" = 'group'::text;`);
133
+ await this.queryRun(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} (
132
134
  "guid" BYTEA NOT NULL,
133
135
  "name" TEXT NOT NULL,
134
136
  "truthy" BOOLEAN,
@@ -138,16 +140,16 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
138
140
  FOREIGN KEY ("guid")
139
141
  REFERENCES ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ("guid") MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE
140
142
  ) WITH ( OIDS=FALSE );`);
141
- this.queryRunSync(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
142
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid`)};`);
143
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("guid");`);
144
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_name`)};`);
145
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_name`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("name");`);
146
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_truthy`)};`);
147
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_truthy`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("guid", "name") WHERE "truthy" = TRUE;`);
148
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_falsy`)};`);
149
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_falsy`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("guid", "name") WHERE "truthy" <> TRUE;`);
150
- this.queryRunSync(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} (
143
+ await this.queryRun(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
144
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid`)};`);
145
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("guid");`);
146
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_name`)};`);
147
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_name`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("name");`);
148
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_truthy`)};`);
149
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_truthy`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("guid", "name") WHERE "truthy" = TRUE;`);
150
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_falsy`)};`);
151
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}_id_guid_name_falsy`)} ON ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} USING btree ("guid", "name") WHERE "truthy" <> TRUE;`);
152
+ await this.queryRun(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} (
151
153
  "guid" BYTEA NOT NULL,
152
154
  "name" TEXT NOT NULL,
153
155
  "reference" BYTEA NOT NULL,
@@ -155,21 +157,21 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
155
157
  FOREIGN KEY ("guid")
156
158
  REFERENCES ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ("guid") MATCH SIMPLE ON UPDATE NO ACTION ON DELETE CASCADE
157
159
  ) WITH ( OIDS=FALSE );`);
158
- this.queryRunSync(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
159
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_guid`)};`);
160
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_guid`)} ON ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} USING btree ("guid");`);
161
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_name`)};`);
162
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_name`)} ON ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} USING btree ("name");`);
163
- this.queryRunSync(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_reference`)};`);
164
- this.queryRunSync(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_reference`)} ON ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} USING btree ("reference");`);
160
+ await this.queryRun(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
161
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_guid`)};`);
162
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_guid`)} ON ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} USING btree ("guid");`);
163
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_name`)};`);
164
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_name`)} ON ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} USING btree ("name");`);
165
+ await this.queryRun(`DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_reference`)};`);
166
+ await this.queryRun(`CREATE INDEX ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}_id_reference`)} ON ${PostgreSQLDriver.escape(`${this.prefix}references_${etype}`)} USING btree ("reference");`);
165
167
  }
166
168
  else {
167
- this.queryRunSync(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}uids`)} (
169
+ await this.queryRun(`CREATE TABLE IF NOT EXISTS ${PostgreSQLDriver.escape(`${this.prefix}uids`)} (
168
170
  "name" TEXT NOT NULL,
169
171
  "cur_uid" BIGINT NOT NULL,
170
172
  PRIMARY KEY ("name")
171
173
  ) WITH ( OIDS = FALSE );`);
172
- this.queryRunSync(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}uids`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
174
+ await this.queryRun(`ALTER TABLE ${PostgreSQLDriver.escape(`${this.prefix}uids`)} OWNER TO ${PostgreSQLDriver.escape(this.config.user)};`);
173
175
  }
174
176
  return true;
175
177
  }
@@ -192,9 +194,9 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
192
194
  }
193
195
  catch (e) {
194
196
  const errorCode = e?.code;
195
- if (errorCode === '42P01' && this.createTables()) {
197
+ if (errorCode === '42P01' && (await this.createTables())) {
196
198
  for (let etype of etypes) {
197
- this.createTables(etype);
199
+ await this.createTables(etype);
198
200
  }
199
201
  try {
200
202
  return await runQuery();
@@ -208,28 +210,6 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
208
210
  }
209
211
  }
210
212
  }
211
- querySync(runQuery, query, etypes = []) {
212
- try {
213
- return runQuery();
214
- }
215
- catch (e) {
216
- const errorCode = e?.code;
217
- if (errorCode === '42P01' && this.createTables()) {
218
- for (let etype of etypes) {
219
- this.createTables(etype);
220
- }
221
- try {
222
- return runQuery();
223
- }
224
- catch (e2) {
225
- throw new nymph_1.QueryFailedError('Query failed: ' + e2?.code + ' - ' + e2?.message, query);
226
- }
227
- }
228
- else {
229
- throw e;
230
- }
231
- }
232
- }
233
213
  queryIter(query, { etypes = [], params = {}, } = {}) {
234
214
  const { query: newQuery, params: newParams } = this.translateQuery(query, params);
235
215
  return this.query(async () => {
@@ -246,35 +226,6 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
246
226
  return results.rows;
247
227
  }, `${query} -- ${JSON.stringify(params)}`, etypes);
248
228
  }
249
- queryIterSync(query, { etypes = [], params = {}, } = {}) {
250
- const { query: newQuery, params: newParams } = this.translateQuery(query, params);
251
- return this.querySync(() => {
252
- const output = child_process_1.default.spawnSync(process.argv0, [__dirname + '/runPostgresqlSync.js'], {
253
- input: JSON.stringify({
254
- postgresqlConfig: this.postgresqlConfig,
255
- query: newQuery,
256
- params: newParams,
257
- }),
258
- timeout: 30000,
259
- maxBuffer: 100 * 1024 * 1024,
260
- encoding: 'utf8',
261
- windowsHide: true,
262
- });
263
- try {
264
- return JSON.parse(output.stdout).rows;
265
- }
266
- catch (e) {
267
- }
268
- if (output.status === 0) {
269
- throw new Error('Unknown parse error.');
270
- }
271
- const err = JSON.parse(output.stderr);
272
- const e = new Error(err.name);
273
- for (const name in err) {
274
- e[name] = err[name];
275
- }
276
- }, `${query} -- ${JSON.stringify(params)}`, etypes);
277
- }
278
229
  queryGet(query, { etypes = [], params = {}, } = {}) {
279
230
  const { query: newQuery, params: newParams } = this.translateQuery(query, params);
280
231
  return this.query(async () => {
@@ -307,36 +258,6 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
307
258
  return { rowCount: results.rowCount ?? 0 };
308
259
  }, `${query} -- ${JSON.stringify(params)}`, etypes);
309
260
  }
310
- queryRunSync(query, { etypes = [], params = {}, } = {}) {
311
- const { query: newQuery, params: newParams } = this.translateQuery(query, params);
312
- return this.querySync(() => {
313
- const output = child_process_1.default.spawnSync(process.argv0, [__dirname + '/runPostgresqlSync.js'], {
314
- input: JSON.stringify({
315
- postgresqlConfig: this.postgresqlConfig,
316
- query: newQuery,
317
- params: newParams,
318
- }),
319
- timeout: 30000,
320
- maxBuffer: 100 * 1024 * 1024,
321
- encoding: 'utf8',
322
- windowsHide: true,
323
- });
324
- try {
325
- const results = JSON.parse(output.stdout);
326
- return { rowCount: results.rowCount ?? 0 };
327
- }
328
- catch (e) {
329
- }
330
- if (output.status === 0) {
331
- throw new Error('Unknown parse error.');
332
- }
333
- const err = JSON.parse(output.stderr);
334
- const e = new Error(err.name);
335
- for (const name in err) {
336
- e[name] = err[name];
337
- }
338
- }, `${query} -- ${JSON.stringify(params)}`, etypes);
339
- }
340
261
  async commit(name) {
341
262
  if (name == null || typeof name !== 'string' || name.length === 0) {
342
263
  throw new nymph_1.InvalidParametersError('Transaction commit attempted without a name.');
@@ -484,6 +405,7 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
484
405
  const fTable = `f${tableSuffix}`;
485
406
  const ieTable = `ie${tableSuffix}`;
486
407
  const countTable = `count${tableSuffix}`;
408
+ const sTable = `s${tableSuffix}`;
487
409
  const sort = options.sort ?? 'cdate';
488
410
  const queryParts = this.iterateSelectorsForQuery(formattedSelectors, (key, value, typeIsOr, typeIsNot) => {
489
411
  const clauseNot = key.startsWith('!');
@@ -1255,18 +1177,38 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1255
1177
  return curQuery;
1256
1178
  });
1257
1179
  let sortBy;
1180
+ let sortByInner;
1181
+ let sortJoin = '';
1182
+ let sortJoinInner = '';
1183
+ const order = options.reverse ? ' DESC' : '';
1258
1184
  switch (sort) {
1259
1185
  case 'mdate':
1260
- sortBy = '"mdate"';
1186
+ sortBy = `${eTable}."mdate"${order}`;
1187
+ sortByInner = `${ieTable}."mdate"${order}`;
1261
1188
  break;
1262
1189
  case 'cdate':
1190
+ sortBy = `${eTable}."cdate"${order}`;
1191
+ sortByInner = `${ieTable}."cdate"${order}`;
1192
+ break;
1263
1193
  default:
1264
- sortBy = '"cdate"';
1194
+ const name = `param${++count.i}`;
1195
+ sortJoin = `LEFT JOIN (
1196
+ SELECT "guid", "string", "number"
1197
+ FROM ${PostgreSQLDriver.escape(this.prefix + 'comparisons_' + etype)}
1198
+ WHERE "name"=@${name}
1199
+ ORDER BY "number"${order}, "string"${order}
1200
+ ) ${sTable} ON ${eTable}."guid"=${sTable}."guid"`;
1201
+ sortJoinInner = `LEFT JOIN (
1202
+ SELECT "guid", "string", "number"
1203
+ FROM ${PostgreSQLDriver.escape(this.prefix + 'comparisons_' + etype)}
1204
+ WHERE "name"=@${name}
1205
+ ORDER BY "number"${order}, "string"${order}
1206
+ ) ${sTable} ON ${ieTable}."guid"=${sTable}."guid"`;
1207
+ sortBy = `${sTable}."number"${order}, ${sTable}."string"${order}`;
1208
+ sortByInner = sortBy;
1209
+ params[name] = sort;
1265
1210
  break;
1266
1211
  }
1267
- if (options.reverse) {
1268
- sortBy += ' DESC';
1269
- }
1270
1212
  let query;
1271
1213
  if (queryParts.length) {
1272
1214
  if (subquery) {
@@ -1302,8 +1244,9 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1302
1244
  : `${ieTable}."guid"`;
1303
1245
  query = `SELECT ${guidColumn} AS "guid"
1304
1246
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${ieTable}
1247
+ ${sortJoinInner}
1305
1248
  WHERE (${whereClause})
1306
- ORDER BY ${ieTable}.${sortBy}${limit}${offset}`;
1249
+ ORDER BY ${sortByInner}, ${ieTable}."guid"${limit}${offset}`;
1307
1250
  }
1308
1251
  else {
1309
1252
  query = `SELECT
@@ -1318,13 +1261,15 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1318
1261
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${eTable}
1319
1262
  LEFT JOIN ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} ${dTable} ON ${eTable}."guid"=${dTable}."guid"
1320
1263
  INNER JOIN ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} ${cTable} ON ${dTable}."guid"=${cTable}."guid" AND ${dTable}."name"=${cTable}."name"
1264
+ ${sortJoin}
1321
1265
  INNER JOIN (
1322
1266
  SELECT ${ieTable}."guid"
1323
1267
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${ieTable}
1268
+ ${sortJoinInner}
1324
1269
  WHERE (${whereClause})
1325
- ORDER BY ${ieTable}.${sortBy}${limit}${offset}
1270
+ ORDER BY ${sortByInner}${limit}${offset}
1326
1271
  ) ${fTable} ON ${eTable}."guid"=${fTable}."guid"
1327
- ORDER BY ${eTable}.${sortBy}`;
1272
+ ORDER BY ${sortBy}, ${eTable}."guid"`;
1328
1273
  }
1329
1274
  }
1330
1275
  }
@@ -1359,7 +1304,8 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1359
1304
  : `${ieTable}."guid"`;
1360
1305
  query = `SELECT ${guidColumn} AS "guid"
1361
1306
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${ieTable}
1362
- ORDER BY ${ieTable}.${sortBy}${limit}${offset}`;
1307
+ ${sortJoinInner}
1308
+ ORDER BY ${sortByInner}, ${ieTable}."guid"${limit}${offset}`;
1363
1309
  }
1364
1310
  else {
1365
1311
  if (limit || offset) {
@@ -1375,12 +1321,14 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1375
1321
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${eTable}
1376
1322
  LEFT JOIN ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} ${dTable} ON ${eTable}."guid"=${dTable}."guid"
1377
1323
  INNER JOIN ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} ${cTable} ON ${dTable}."guid"=${cTable}."guid" AND ${dTable}."name"=${cTable}."name"
1324
+ ${sortJoin}
1378
1325
  INNER JOIN (
1379
1326
  SELECT ${ieTable}."guid"
1380
1327
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${ieTable}
1381
- ORDER BY ${ieTable}.${sortBy}${limit}${offset}
1328
+ ${sortJoinInner}
1329
+ ORDER BY ${sortByInner}${limit}${offset}
1382
1330
  ) ${fTable} ON ${eTable}."guid"=${fTable}."guid"
1383
- ORDER BY ${eTable}.${sortBy}`;
1331
+ ORDER BY ${sortBy}, ${eTable}."guid"`;
1384
1332
  }
1385
1333
  else {
1386
1334
  query = `SELECT
@@ -1395,7 +1343,8 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1395
1343
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ${eTable}
1396
1344
  LEFT JOIN ${PostgreSQLDriver.escape(`${this.prefix}data_${etype}`)} ${dTable} ON ${eTable}."guid"=${dTable}."guid"
1397
1345
  INNER JOIN ${PostgreSQLDriver.escape(`${this.prefix}comparisons_${etype}`)} ${cTable} ON ${dTable}."guid"=${cTable}."guid" AND ${dTable}."name"=${cTable}."name"
1398
- ORDER BY ${eTable}.${sortBy}`;
1346
+ ${sortJoin}
1347
+ ORDER BY ${sortBy}, ${eTable}."guid"`;
1399
1348
  }
1400
1349
  }
1401
1350
  }
@@ -1416,13 +1365,6 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1416
1365
  result,
1417
1366
  };
1418
1367
  }
1419
- performQuerySync(options, formattedSelectors, etype) {
1420
- const { query, params, etypes } = this.makeEntityQuery(options, formattedSelectors, etype);
1421
- const result = (this.queryIterSync(query, { etypes, params }) || [])[Symbol.iterator]();
1422
- return {
1423
- result,
1424
- };
1425
- }
1426
1368
  async getEntities(options = {}, ...selectors) {
1427
1369
  const { result: resultPromise, process } = this.getEntitesRowLike(options, selectors, (options, formattedSelectors, etype) => this.performQuery(options, formattedSelectors, etype), () => {
1428
1370
  const next = result.next();
@@ -1446,28 +1388,6 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1446
1388
  }
1447
1389
  return value;
1448
1390
  }
1449
- getEntitiesSync(options = {}, ...selectors) {
1450
- const { result, process } = this.getEntitesRowLike(options, selectors, (options, formattedSelectors, etype) => this.performQuerySync(options, formattedSelectors, etype), () => {
1451
- const next = result.next();
1452
- return next.done ? null : next.value;
1453
- }, () => undefined, (row) => Number(row.count), (row) => row.guid, (row) => ({
1454
- tags: row.tags,
1455
- cdate: isNaN(Number(row.cdate)) ? null : Number(row.cdate),
1456
- mdate: isNaN(Number(row.mdate)) ? null : Number(row.mdate),
1457
- }), (row) => ({
1458
- name: row.name,
1459
- svalue: row.value === 'N'
1460
- ? JSON.stringify(Number(row.number))
1461
- : row.value === 'S'
1462
- ? JSON.stringify(row.string)
1463
- : row.value,
1464
- }));
1465
- const value = process();
1466
- if (value instanceof Error) {
1467
- throw value;
1468
- }
1469
- return value;
1470
- }
1471
1391
  async getUID(name) {
1472
1392
  if (name == null) {
1473
1393
  throw new nymph_1.InvalidParametersError('Name not given for UID.');
@@ -1710,6 +1630,10 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1710
1630
  };
1711
1631
  try {
1712
1632
  const result = await this.saveEntityRowLike(entity, async (_entity, guid, tags, data, sdata, cdate, etype) => {
1633
+ if (Object.keys(data).length === 0 &&
1634
+ Object.keys(sdata).length === 0) {
1635
+ return false;
1636
+ }
1713
1637
  await this.queryRun(`INSERT INTO ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} ("guid", "tags", "cdate", "mdate") VALUES (decode(@guid, 'hex'), @tags, @cdate, @cdate);`, {
1714
1638
  etypes: [etype],
1715
1639
  params: {
@@ -1721,6 +1645,10 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1721
1645
  await insertData(guid, data, sdata, etype);
1722
1646
  return true;
1723
1647
  }, async (entity, guid, tags, data, sdata, mdate, etype) => {
1648
+ if (Object.keys(data).length === 0 &&
1649
+ Object.keys(sdata).length === 0) {
1650
+ return false;
1651
+ }
1724
1652
  const promises = [];
1725
1653
  promises.push(this.queryRun(`SELECT 1 FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} WHERE "guid"=decode(@guid, 'hex') FOR UPDATE;`, {
1726
1654
  etypes: [etype],
@@ -1848,8 +1776,7 @@ class PostgreSQLDriver extends nymph_1.NymphDriver {
1848
1776
  this.transaction = null;
1849
1777
  }
1850
1778
  const nymph = this.nymph.clone();
1851
- nymph.driver = new PostgreSQLDriver(this.config, this.link, transaction);
1852
- nymph.driver.init(nymph);
1779
+ nymph.driver.transaction = transaction;
1853
1780
  return nymph;
1854
1781
  }
1855
1782
  }