@trenskow/pged 5.0.21 → 5.0.23
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/package.json +3 -3
- package/query-builder.js +10 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trenskow/pged",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.23",
|
|
4
4
|
"description": "Just a silly little db management and query builder for PostgreSQL.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/trenskow/pged#readme",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@trenskow/async-event-emitter": "^0.1.
|
|
27
|
-
"@trenskow/caseit": "^1.3.
|
|
26
|
+
"@trenskow/async-event-emitter": "^0.1.7",
|
|
27
|
+
"@trenskow/caseit": "^1.3.6",
|
|
28
28
|
"@trenskow/custom-promise": "^0.10.3",
|
|
29
29
|
"pg": "^8.11.1",
|
|
30
30
|
"puqeue": "^1.0.12"
|
package/query-builder.js
CHANGED
|
@@ -201,7 +201,8 @@ export default class QueryBuilder extends CustomPromise {
|
|
|
201
201
|
options.local = options.local || this._defaultPrimaryKey;
|
|
202
202
|
options.foreign = options.foreign || this._defaultPrimaryKey;
|
|
203
203
|
let local = options.local.substring(0, 1) == ':' ? this._dbCase(options.local) : `:${this._table}.${this._dbCase(options.local)}`;
|
|
204
|
-
let
|
|
204
|
+
let direct = local.substring(0, 1) == ':' ? ':' : '';
|
|
205
|
+
let foreign = options.foreign.substring(0, 1) == ':' ? `${direct}${this._dbCase(options.foreign.substring(1))}` : `${direct}${this._dbCase(options.table)}.${this._dbCase(options.foreign)}`;
|
|
205
206
|
options.conditions[local] = foreign;
|
|
206
207
|
}
|
|
207
208
|
options.conditions = this._formalizeConditions(options.conditions);
|
|
@@ -367,8 +368,14 @@ export default class QueryBuilder extends CustomPromise {
|
|
|
367
368
|
}
|
|
368
369
|
|
|
369
370
|
if (key.substring(0, 1) == ':') {
|
|
370
|
-
|
|
371
|
-
|
|
371
|
+
let value = condition[key];
|
|
372
|
+
if (typeof value === 'string' && value.substring(0, 1) == ':') {
|
|
373
|
+
value = this._dbCase(condition[key].substring(1));
|
|
374
|
+
} else {
|
|
375
|
+
this._queryParameters.push(this._formatParameter(key, condition[key]));
|
|
376
|
+
value = `$${this._queryParameters.length}`;
|
|
377
|
+
}
|
|
378
|
+
return this._buildCondition(key.substring(1), comparer, value);
|
|
372
379
|
}
|
|
373
380
|
|
|
374
381
|
let dbKey = key;
|