drizzle-orm 0.10.2 → 0.10.6
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/README.md +12 -2
- package/builders/aggregators/deleteAggregator.d.ts +5 -1
- package/builders/aggregators/deleteAggregator.js +5 -2
- package/builders/aggregators/insertAggregator.d.ts +5 -1
- package/builders/aggregators/insertAggregator.js +18 -9
- package/builders/aggregators/selectAggregator.d.ts +6 -1
- package/builders/aggregators/selectAggregator.js +10 -6
- package/builders/aggregators/updateAggregator.d.ts +5 -1
- package/builders/aggregators/updateAggregator.js +9 -3
- package/builders/highLvlBuilders/deleteRequestBuilder.js +5 -2
- package/builders/highLvlBuilders/insertRequestBuilder.js +5 -2
- package/builders/highLvlBuilders/selectRequestBuilder.js +7 -2
- package/builders/highLvlBuilders/updateRequestBuilder.js +6 -2
- package/builders/joinBuilders/builders/abstractJoinBuilder.js +7 -3
- package/builders/lowLvlBuilders/delets/deleteFilter.d.ts +4 -1
- package/builders/lowLvlBuilders/delets/deleteFrom.d.ts +4 -1
- package/builders/lowLvlBuilders/inserts/insertInto.d.ts +4 -1
- package/builders/lowLvlBuilders/inserts/onConflictInsert.d.ts +4 -1
- package/builders/lowLvlBuilders/inserts/valuesInsert.d.ts +4 -1
- package/builders/lowLvlBuilders/selects/selectFrom.d.ts +4 -1
- package/builders/lowLvlBuilders/selects/selectJoined.d.ts +4 -1
- package/builders/lowLvlBuilders/selects/whereSelect.d.ts +4 -1
- package/builders/lowLvlBuilders/updates/updateIn.d.ts +4 -1
- package/builders/lowLvlBuilders/updates/whereSelect.d.ts +4 -1
- package/builders/lowLvlBuilders/updates/whereSet.d.ts +4 -1
- package/builders/requestBuilders/updates/combine.d.ts +4 -1
- package/builders/requestBuilders/updates/combine.js +8 -3
- package/builders/requestBuilders/updates/increment.d.ts +4 -1
- package/builders/requestBuilders/updates/increment.js +4 -1
- package/builders/requestBuilders/updates/setObjects.d.ts +4 -1
- package/builders/requestBuilders/updates/setObjects.js +5 -1
- package/builders/requestBuilders/updates/updates.d.ts +4 -1
- package/builders/requestBuilders/where/and.d.ts +6 -1
- package/builders/requestBuilders/where/and.js +9 -3
- package/builders/requestBuilders/where/const.d.ts +4 -1
- package/builders/requestBuilders/where/const.js +6 -4
- package/builders/requestBuilders/where/constArray.d.ts +4 -1
- package/builders/requestBuilders/where/constArray.js +11 -5
- package/builders/requestBuilders/where/eqWhere.d.ts +6 -1
- package/builders/requestBuilders/where/eqWhere.js +6 -1
- package/builders/requestBuilders/where/greater.d.ts +6 -1
- package/builders/requestBuilders/where/greater.js +6 -1
- package/builders/requestBuilders/where/greaterEq.d.ts +6 -1
- package/builders/requestBuilders/where/greaterEq.js +6 -1
- package/builders/requestBuilders/where/in.d.ts +6 -1
- package/builders/requestBuilders/where/in.js +6 -1
- package/builders/requestBuilders/where/isNull.d.ts +6 -1
- package/builders/requestBuilders/where/isNull.js +5 -1
- package/builders/requestBuilders/where/less.d.ts +6 -1
- package/builders/requestBuilders/where/less.js +6 -1
- package/builders/requestBuilders/where/lessEq.d.ts +6 -1
- package/builders/requestBuilders/where/lessEq.js +6 -1
- package/builders/requestBuilders/where/like.d.ts +6 -1
- package/builders/requestBuilders/where/like.js +6 -1
- package/builders/requestBuilders/where/notEqWhere.d.ts +6 -1
- package/builders/requestBuilders/where/notEqWhere.js +6 -1
- package/builders/requestBuilders/where/or.d.ts +6 -1
- package/builders/requestBuilders/where/or.js +9 -3
- package/builders/requestBuilders/where/rawWhere.d.ts +4 -1
- package/builders/requestBuilders/where/rawWhere.js +2 -1
- package/builders/requestBuilders/where/var.d.ts +6 -1
- package/builders/requestBuilders/where/var.js +4 -1
- package/builders/requestBuilders/where/where.d.ts +6 -1
- package/builders/requestBuilders/where/where.js +1 -0
- package/columns/types/pgEnum.js +1 -1
- package/columns/types/pgInteger.d.ts +1 -1
- package/columns/types/pgInteger.js +1 -1
- package/columns/types/pgJsonb.js +3 -1
- package/columns/types/pgSerial.d.ts +1 -1
- package/columns/types/pgSerial.js +1 -1
- package/columns/types/pgSmallInt.d.ts +1 -1
- package/columns/types/pgSmallInt.js +1 -1
- package/columns/types/pgText.js +1 -1
- package/columns/types/pgTimestamp.js +1 -1
- package/columns/types/pgTimestamptz.js +1 -1
- package/columns/types/pgVarChar.js +1 -1
- package/data/tables/citiesTable.d.ts +14 -0
- package/data/tables/citiesTable.js +17 -0
- package/data/tables/userGroupsTable.d.ts +7 -0
- package/data/tables/userGroupsTable.js +15 -0
- package/data/tables/usersTable.d.ts +16 -0
- package/data/tables/usersTable.js +31 -0
- package/data/tables/usersToUserGroups.d.ts +7 -0
- package/data/tables/usersToUserGroups.js +17 -0
- package/data/types/rolesType.d.ts +1 -0
- package/data/types/rolesType.js +6 -0
- package/db/session.d.ts +2 -2
- package/db/session.js +2 -2
- package/docs/cases/simple_delete.js +5 -3
- package/docs/cases/simple_insert.js +7 -9
- package/docs/cases/simple_join.js +9 -7
- package/docs/cases/simple_select.js +4 -2
- package/docs/cases/simple_update.js +5 -2
- package/docs/tables/usersTable.d.ts +11 -10
- package/docs/tables/usersTable.js +5 -4
- package/mappers/responseMapper.js +2 -2
- package/migrator/migrator.js +10 -2
- package/package.json +1 -1
- package/tables/abstractTable.d.ts +2 -1
- package/test.js +104 -9
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class And extends where_1.default {
|
|
5
6
|
constructor(expressions) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () => {
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
let nextPosition = position || 1;
|
|
8
10
|
const result = ['('];
|
|
11
|
+
const valuesResult = [];
|
|
9
12
|
for (let i = 0; i < this.expressions.length; i += 1) {
|
|
10
13
|
const expression = this.expressions[i];
|
|
11
|
-
|
|
14
|
+
const expressionResult = expression.toQuery(nextPosition, tableCache);
|
|
15
|
+
valuesResult.push(...expressionResult.values);
|
|
16
|
+
result.push(expressionResult.query);
|
|
17
|
+
nextPosition += expressionResult.values.length;
|
|
12
18
|
if (i < this.expressions.length - 1) {
|
|
13
19
|
result.push(' and ');
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
result.push(')');
|
|
17
|
-
return result.join('');
|
|
23
|
+
return { query: result.join(''), values: valuesResult };
|
|
18
24
|
};
|
|
19
25
|
this.expressions = expressions;
|
|
20
26
|
}
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable no-return-assign */
|
|
3
4
|
const ecranate_1 = require("../../../utils/ecranate");
|
|
4
5
|
const where_1 = require("./where");
|
|
5
6
|
class Const extends where_1.default {
|
|
6
7
|
constructor(value) {
|
|
7
8
|
super();
|
|
8
|
-
this.toQuery = () => {
|
|
9
|
+
this.toQuery = (position) => {
|
|
10
|
+
const nextPosition = position || 1;
|
|
9
11
|
if (this.value instanceof Date) {
|
|
10
|
-
return
|
|
12
|
+
return { query: `$${nextPosition}`, values: [`${this.value.toISOString()}`] };
|
|
11
13
|
}
|
|
12
14
|
if (ecranate_1.shouldEcranate(this.value)) {
|
|
13
|
-
return
|
|
15
|
+
return { query: `$${nextPosition}`, values: [`${this.value.toString()}`] };
|
|
14
16
|
}
|
|
15
|
-
return this.value
|
|
17
|
+
return { query: `$${nextPosition}`, values: [this.value] };
|
|
16
18
|
};
|
|
17
19
|
this.value = value;
|
|
18
20
|
}
|
|
@@ -5,24 +5,30 @@ const where_1 = require("./where");
|
|
|
5
5
|
class ConstArray extends where_1.default {
|
|
6
6
|
constructor(values) {
|
|
7
7
|
super();
|
|
8
|
-
this.toQuery = () => {
|
|
8
|
+
this.toQuery = (position) => {
|
|
9
|
+
let nextPosition = position || 1;
|
|
9
10
|
const finalArray = [];
|
|
11
|
+
const finalValues = [];
|
|
10
12
|
for (let i = 0; i < this.values.length; i += 1) {
|
|
11
13
|
const value = this.values[i];
|
|
12
14
|
if (value instanceof Date) {
|
|
13
|
-
|
|
15
|
+
finalArray.push(`$${nextPosition}`);
|
|
16
|
+
finalValues.push(`${value.toISOString()}`);
|
|
14
17
|
}
|
|
15
18
|
if (ecranate_1.shouldEcranate(value)) {
|
|
16
|
-
finalArray.push(
|
|
19
|
+
finalArray.push(`$${nextPosition}`);
|
|
20
|
+
finalValues.push(`${value.toString()}`);
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
|
-
finalArray.push(
|
|
23
|
+
finalArray.push(`$${nextPosition}`);
|
|
24
|
+
finalValues.push(value);
|
|
20
25
|
}
|
|
21
26
|
if (i < this.values.length - 1) {
|
|
22
27
|
finalArray.push(',');
|
|
23
28
|
}
|
|
29
|
+
nextPosition += 1;
|
|
24
30
|
}
|
|
25
|
-
return finalArray.join('');
|
|
31
|
+
return { query: finalArray.join(','), values: finalValues };
|
|
26
32
|
};
|
|
27
33
|
this.values = values;
|
|
28
34
|
}
|
|
@@ -3,5 +3,10 @@ export default class EqWhere extends Expr {
|
|
|
3
3
|
private left;
|
|
4
4
|
private right;
|
|
5
5
|
constructor(left: Expr, right: Expr);
|
|
6
|
-
toQuery: (
|
|
6
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
7
|
+
[tableName: string]: string;
|
|
8
|
+
} | undefined) => {
|
|
9
|
+
query: string;
|
|
10
|
+
values: Array<any>;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class EqWhere extends where_1.default {
|
|
5
6
|
constructor(left, right) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query}=${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class Greater extends where_1.default {
|
|
5
6
|
constructor({ left, right }) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query} > ${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class GreaterEq extends where_1.default {
|
|
5
6
|
constructor({ left, right }) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query} >= ${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -3,5 +3,10 @@ export default class In extends Expr {
|
|
|
3
3
|
private left;
|
|
4
4
|
private right;
|
|
5
5
|
constructor(left: Expr, right: Expr);
|
|
6
|
-
toQuery: (
|
|
6
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
7
|
+
[tableName: string]: string;
|
|
8
|
+
} | undefined) => {
|
|
9
|
+
query: string;
|
|
10
|
+
values: Array<any>;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class In extends where_1.default {
|
|
5
6
|
constructor(left, right) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query} in (${rightPreparedValues.query})`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -2,5 +2,10 @@ import Expr from './where';
|
|
|
2
2
|
export default class IsNull extends Expr {
|
|
3
3
|
private left;
|
|
4
4
|
constructor(left: Expr);
|
|
5
|
-
toQuery: (
|
|
5
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
6
|
+
[tableName: string]: string;
|
|
7
|
+
} | undefined) => {
|
|
8
|
+
query: string;
|
|
9
|
+
values: Array<any>;
|
|
10
|
+
};
|
|
6
11
|
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class IsNull extends where_1.default {
|
|
5
6
|
constructor(left) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
10
|
+
return { query: `${leftPreparedValues.query} is null`, values: leftPreparedValues.values };
|
|
11
|
+
};
|
|
8
12
|
this.left = left;
|
|
9
13
|
}
|
|
10
14
|
}
|
|
@@ -6,5 +6,10 @@ export default class Less extends Expr {
|
|
|
6
6
|
left: Expr;
|
|
7
7
|
right: Expr;
|
|
8
8
|
});
|
|
9
|
-
toQuery: (
|
|
9
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
10
|
+
[tableName: string]: string;
|
|
11
|
+
} | undefined) => {
|
|
12
|
+
query: string;
|
|
13
|
+
values: Array<any>;
|
|
14
|
+
};
|
|
10
15
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class Less extends where_1.default {
|
|
5
6
|
constructor({ left, right }) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query} < ${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -6,5 +6,10 @@ export default class LessEq extends Expr {
|
|
|
6
6
|
left: Expr;
|
|
7
7
|
right: Expr;
|
|
8
8
|
});
|
|
9
|
-
toQuery: (
|
|
9
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
10
|
+
[tableName: string]: string;
|
|
11
|
+
} | undefined) => {
|
|
12
|
+
query: string;
|
|
13
|
+
values: Array<any>;
|
|
14
|
+
};
|
|
10
15
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class LessEq extends where_1.default {
|
|
5
6
|
constructor({ left, right }) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query} <= ${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -3,5 +3,10 @@ export default class Like extends Expr {
|
|
|
3
3
|
private left;
|
|
4
4
|
private right;
|
|
5
5
|
constructor(left: Expr, right: Expr);
|
|
6
|
-
toQuery: (
|
|
6
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
7
|
+
[tableName: string]: string;
|
|
8
|
+
} | undefined) => {
|
|
9
|
+
query: string;
|
|
10
|
+
values: Array<any>;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class Like extends where_1.default {
|
|
5
6
|
constructor(left, right) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query} like ${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -3,5 +3,10 @@ export default class NotEqWhere extends Expr {
|
|
|
3
3
|
private left;
|
|
4
4
|
private right;
|
|
5
5
|
constructor(left: Expr, right: Expr);
|
|
6
|
-
toQuery: (
|
|
6
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
7
|
+
[tableName: string]: string;
|
|
8
|
+
} | undefined) => {
|
|
9
|
+
query: string;
|
|
10
|
+
values: Array<any>;
|
|
11
|
+
};
|
|
7
12
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class NotEqWhere extends where_1.default {
|
|
5
6
|
constructor(left, right) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
const rightPreparedValues = this.right.toQuery(position, tableCache);
|
|
10
|
+
const leftPreparedValues = this.left.toQuery(position, tableCache);
|
|
11
|
+
return { query: `${leftPreparedValues.query}!=${rightPreparedValues.query}`, values: [...leftPreparedValues.values, ...rightPreparedValues.values] };
|
|
12
|
+
};
|
|
8
13
|
this.left = left;
|
|
9
14
|
this.right = right;
|
|
10
15
|
}
|
|
@@ -2,5 +2,10 @@ import Expr from './where';
|
|
|
2
2
|
export default class Or extends Expr {
|
|
3
3
|
private expressions;
|
|
4
4
|
constructor(expressions: Expr[]);
|
|
5
|
-
toQuery: (
|
|
5
|
+
toQuery: (position?: number | undefined, tableCache?: {
|
|
6
|
+
[tableName: string]: string;
|
|
7
|
+
} | undefined) => {
|
|
8
|
+
query: string;
|
|
9
|
+
values: Array<any>;
|
|
10
|
+
};
|
|
6
11
|
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class Or extends where_1.default {
|
|
5
6
|
constructor(expressions) {
|
|
6
7
|
super();
|
|
7
|
-
this.toQuery = () => {
|
|
8
|
+
this.toQuery = (position, tableCache) => {
|
|
9
|
+
let nextPosition = position || 1;
|
|
8
10
|
const result = ['('];
|
|
11
|
+
const valuesResult = [];
|
|
9
12
|
for (let i = 0; i < this.expressions.length; i += 1) {
|
|
10
13
|
const expression = this.expressions[i];
|
|
11
|
-
|
|
14
|
+
const expressionResult = expression.toQuery(nextPosition, tableCache);
|
|
15
|
+
valuesResult.push(...expressionResult.values);
|
|
16
|
+
result.push(expressionResult.query);
|
|
17
|
+
nextPosition += expressionResult.values.length;
|
|
12
18
|
if (i < this.expressions.length - 1) {
|
|
13
19
|
result.push(' or ');
|
|
14
20
|
}
|
|
15
21
|
}
|
|
16
22
|
result.push(')');
|
|
17
|
-
return result.join('');
|
|
23
|
+
return { query: result.join(''), values: valuesResult };
|
|
18
24
|
};
|
|
19
25
|
this.expressions = expressions;
|
|
20
26
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const where_1 = require("./where");
|
|
4
5
|
class RawWhere extends where_1.default {
|
|
5
6
|
constructor(custom) {
|
|
6
7
|
super();
|
|
7
8
|
this.custom = custom;
|
|
8
|
-
this.toQuery = () => this.custom;
|
|
9
|
+
this.toQuery = () => ({ query: this.custom, values: [] });
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
exports.default = RawWhere;
|
|
@@ -4,5 +4,10 @@ import Expr from './where';
|
|
|
4
4
|
export default class Var<T extends AbstractColumn<ColumnType<any>, boolean, boolean>> extends Expr {
|
|
5
5
|
private column;
|
|
6
6
|
constructor(column: T);
|
|
7
|
-
toQuery: (
|
|
7
|
+
toQuery: (postition?: number | undefined, tableCache?: {
|
|
8
|
+
[tableName: string]: string;
|
|
9
|
+
} | undefined) => {
|
|
10
|
+
query: string;
|
|
11
|
+
values: Array<any>;
|
|
12
|
+
};
|
|
8
13
|
}
|
|
@@ -5,7 +5,10 @@ const where_1 = require("./where");
|
|
|
5
5
|
class Var extends where_1.default {
|
|
6
6
|
constructor(column) {
|
|
7
7
|
super();
|
|
8
|
-
this.toQuery = () =>
|
|
8
|
+
this.toQuery = (postition, tableCache) => {
|
|
9
|
+
const tableName = tableCache && tableCache[this.column.getParentName()] ? tableCache[this.column.getParentName()] : this.column.getParentName();
|
|
10
|
+
return { query: `${tableName}.${ecranate_1.ecranate(this.column.getColumnName())}`, values: [] };
|
|
11
|
+
};
|
|
9
12
|
this.column = column;
|
|
10
13
|
}
|
|
11
14
|
}
|
package/columns/types/pgEnum.js
CHANGED
|
@@ -5,7 +5,7 @@ class PgEnum extends columnType_1.default {
|
|
|
5
5
|
constructor(dbName) {
|
|
6
6
|
super();
|
|
7
7
|
this.getDbName = () => this.dbName;
|
|
8
|
-
this.insertStrategy = (value) =>
|
|
8
|
+
this.insertStrategy = (value) => `${value}`;
|
|
9
9
|
this.dbName = dbName;
|
|
10
10
|
}
|
|
11
11
|
selectStrategy(value) {
|
package/columns/types/pgJsonb.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable max-len */
|
|
3
4
|
const columnType_1 = require("./columnType");
|
|
4
5
|
class PgJsonb extends columnType_1.default {
|
|
5
6
|
constructor() {
|
|
6
7
|
super();
|
|
7
8
|
this.getDbName = () => this.dbName;
|
|
8
|
-
|
|
9
|
+
// public insertStrategy = (value: TCodeType): string => `'${JSON.stringify(value).replace(/'/g, "''")}'::jsonb`;
|
|
10
|
+
this.insertStrategy = (value) => `${JSON.stringify(value).replace(/'/g, "''")}`;
|
|
9
11
|
this.dbName = 'JSONB';
|
|
10
12
|
}
|
|
11
13
|
selectStrategy(value) {
|
package/columns/types/pgText.js
CHANGED
|
@@ -5,7 +5,7 @@ class PgText extends columnType_1.default {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
super();
|
|
7
7
|
this.getDbName = () => this.dbName;
|
|
8
|
-
this.insertStrategy = (value) =>
|
|
8
|
+
this.insertStrategy = (value) => `${value.replace(/'/g, "''")}`;
|
|
9
9
|
this.dbName = 'TEXT';
|
|
10
10
|
}
|
|
11
11
|
selectStrategy(value) {
|
|
@@ -5,7 +5,7 @@ class PgTimestamp extends columnType_1.default {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
super();
|
|
7
7
|
this.getDbName = () => this.dbName;
|
|
8
|
-
this.insertStrategy = (value) =>
|
|
8
|
+
this.insertStrategy = (value) => `${value.toISOString()}`;
|
|
9
9
|
this.dbName = 'timestamp without time zone';
|
|
10
10
|
}
|
|
11
11
|
selectStrategy(value) {
|
|
@@ -5,7 +5,7 @@ class PgTimestamptz extends columnType_1.default {
|
|
|
5
5
|
constructor() {
|
|
6
6
|
super();
|
|
7
7
|
this.getDbName = () => this.dbName;
|
|
8
|
-
this.insertStrategy = (value) =>
|
|
8
|
+
this.insertStrategy = (value) => `${value.toISOString()}`;
|
|
9
9
|
this.dbName = 'timestamp with time zone';
|
|
10
10
|
}
|
|
11
11
|
selectStrategy(value) {
|
|
@@ -5,7 +5,7 @@ class PgVarChar extends columnType_1.default {
|
|
|
5
5
|
constructor(size) {
|
|
6
6
|
super();
|
|
7
7
|
this.getDbName = () => this.dbName;
|
|
8
|
-
this.insertStrategy = (value) =>
|
|
8
|
+
this.insertStrategy = (value) => `${value.replace(/'/g, "''")}`;
|
|
9
9
|
this.size = size;
|
|
10
10
|
if (size) {
|
|
11
11
|
this.dbName = `character varying(${size})`;
|