taon-type-sql 21.0.26 → 21.0.27
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/browser/package.json +1 -1
- package/browser-prod/package.json +1 -1
- package/lib/build-info._auto-generated_.d.ts +1 -1
- package/lib/build-info._auto-generated_.js +1 -1
- package/lib/package.json +1 -1
- package/lib-prod/package.json +1 -1
- package/package.json +1 -1
- package/websql/package.json +1 -1
- package/websql-prod/package.json +1 -1
- package/lib-prod/build-info._auto-generated_.js +0 -26
- package/lib-prod/builder/column/basic-column.js +0 -11
- package/lib-prod/builder/column/boolean-column.js +0 -11
- package/lib-prod/builder/column/comparable-column.js +0 -39
- package/lib-prod/builder/column/date-column.js +0 -11
- package/lib-prod/builder/column/number-column.js +0 -16
- package/lib-prod/builder/column/query-column.js +0 -18
- package/lib-prod/builder/column/string-column.js +0 -33
- package/lib-prod/builder/column/value-column.js +0 -27
- package/lib-prod/builder/condition/query-column-condition.js +0 -16
- package/lib-prod/builder/condition/query-condition-chain.js +0 -26
- package/lib-prod/builder/condition/query-condition.js +0 -4
- package/lib-prod/builder/condition/query-join-condition.js +0 -16
- package/lib-prod/builder/helpers/generics-helper.js +0 -3
- package/lib-prod/builder/helpers/internal-types.js +0 -1
- package/lib-prod/builder/join/joined-tables-chain.js +0 -11
- package/lib-prod/builder/join/joined-tables.js +0 -19
- package/lib-prod/builder/other/query-ordering.js +0 -14
- package/lib-prod/builder/query/select-query.js +0 -45
- package/lib-prod/builder/query/table-condition-query.js +0 -22
- package/lib-prod/builder/query/table-query.js +0 -52
- package/lib-prod/builder/query-source.js +0 -17
- package/lib-prod/builder/query-table.js +0 -22
- package/lib-prod/client/mysql.js +0 -7
- package/lib-prod/client/pg.js +0 -7
- package/lib-prod/client/query-processor.js +0 -69
- package/lib-prod/converter/param-converter.js +0 -26
- package/lib-prod/converter/parameterized-converter.js +0 -14
- package/lib-prod/converter/query-converter.js +0 -280
- package/lib-prod/converter/result-converter.js +0 -85
- package/lib-prod/converter/sql-converter.js +0 -5
- package/lib-prod/converter/type-converter.js +0 -36
- package/lib-prod/converter/types.js +0 -1
- package/lib-prod/env/env.angular-node-app.js +0 -66
- package/lib-prod/env/env.docs-webapp.js +0 -66
- package/lib-prod/env/env.electron-app.js +0 -66
- package/lib-prod/env/env.mobile-app.js +0 -66
- package/lib-prod/env/env.npm-lib-and-cli-tool.js +0 -66
- package/lib-prod/env/env.vscode-plugin.js +0 -66
- package/lib-prod/env/index.js +0 -6
- package/lib-prod/index._auto-generated_.js +0 -5
- package/lib-prod/index.js +0 -25
- package/lib-prod/migrations/index.js +0 -2
- package/lib-prod/migrations/migrations_index._auto-generated_.js +0 -3
package/browser/package.json
CHANGED
|
@@ -25,6 +25,6 @@ exports.CURRENT_PACKAGE_TAON_VERSION = 'v21';
|
|
|
25
25
|
/**
|
|
26
26
|
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
27
27
|
*/
|
|
28
|
-
exports.CURRENT_PACKAGE_VERSION = '21.0.
|
|
28
|
+
exports.CURRENT_PACKAGE_VERSION = '21.0.27';
|
|
29
29
|
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
30
30
|
//# sourceMappingURL=build-info._auto-generated_.js.map
|
package/lib/package.json
CHANGED
package/lib-prod/package.json
CHANGED
package/package.json
CHANGED
package/websql/package.json
CHANGED
package/websql-prod/package.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
2
|
-
/**
|
|
3
|
-
* Autogenerated by current cli tool
|
|
4
|
-
*/
|
|
5
|
-
export const BUILD_FRAMEWORK_CLI_NAME = 'tnp';
|
|
6
|
-
/**
|
|
7
|
-
* This value can be change in taon.jsonc (appId)
|
|
8
|
-
*/
|
|
9
|
-
export const APP_ID = 'com.domain.example.taon-type-sql';
|
|
10
|
-
/**
|
|
11
|
-
* Autogenerated by current cli tool
|
|
12
|
-
*/
|
|
13
|
-
export const BUILD_BASE_HREF = '';
|
|
14
|
-
/**
|
|
15
|
-
* This value can be change in taon.jsonc (overrideNpmName)
|
|
16
|
-
*/
|
|
17
|
-
export const PROJECT_NPM_NAME = 'taon-type-sql';
|
|
18
|
-
/**
|
|
19
|
-
* Taon version from you project taon.json
|
|
20
|
-
*/
|
|
21
|
-
export const CURRENT_PACKAGE_TAON_VERSION = 'v21';
|
|
22
|
-
/**
|
|
23
|
-
* Autogenerated by current cli tool. Use *tnp release* to bump version.
|
|
24
|
-
*/
|
|
25
|
-
export const CURRENT_PACKAGE_VERSION = '21.0.26';
|
|
26
|
-
// THIS FILE IS GENERATED - DO NOT MODIFY
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import QueryColumn from "./query-column";
|
|
2
|
-
import NumberColumn from "./number-column";
|
|
3
|
-
// This file is only needed because the QueryColumn can't implement its count method b. of circular dependencies
|
|
4
|
-
export default class BasicColumn extends QueryColumn {
|
|
5
|
-
constructor(table, name, modifiers = []) {
|
|
6
|
-
super(table, name, modifiers);
|
|
7
|
-
}
|
|
8
|
-
count() {
|
|
9
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import NumberColumn from "./number-column";
|
|
2
|
-
import ValueColumn from "./value-column";
|
|
3
|
-
export default class BooleanColumn extends ValueColumn {
|
|
4
|
-
constructor(table, name, modifiers = []) {
|
|
5
|
-
super(table, name, modifiers);
|
|
6
|
-
this._type = 'boolean';
|
|
7
|
-
}
|
|
8
|
-
count() {
|
|
9
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import QueryColumnCondition from "../condition/query-column-condition";
|
|
2
|
-
import ValueColumn from "./value-column";
|
|
3
|
-
class ComparableColumn extends ValueColumn {
|
|
4
|
-
constructor(table, name, modifiers = []) {
|
|
5
|
-
super(table, name, modifiers);
|
|
6
|
-
}
|
|
7
|
-
lt(value) {
|
|
8
|
-
return new QueryColumnCondition(this, 'lt', value);
|
|
9
|
-
}
|
|
10
|
-
gt(value) {
|
|
11
|
-
return new QueryColumnCondition(this, 'gt', value);
|
|
12
|
-
}
|
|
13
|
-
lte(value) {
|
|
14
|
-
return new QueryColumnCondition(this, 'lte', value);
|
|
15
|
-
}
|
|
16
|
-
gte(value) {
|
|
17
|
-
return new QueryColumnCondition(this, 'gte', value);
|
|
18
|
-
}
|
|
19
|
-
in(values) {
|
|
20
|
-
return new QueryColumnCondition(this, 'in', ...values);
|
|
21
|
-
}
|
|
22
|
-
notIn(values) {
|
|
23
|
-
return new QueryColumnCondition(this, 'not-in', ...values);
|
|
24
|
-
}
|
|
25
|
-
between(value1, value2) {
|
|
26
|
-
return new QueryColumnCondition(this, 'between', value1, value2);
|
|
27
|
-
}
|
|
28
|
-
notBetween(value1, value2) {
|
|
29
|
-
return new QueryColumnCondition(this, 'not-between', value1, value2);
|
|
30
|
-
}
|
|
31
|
-
// min/max exists for text columns too, not just numeric and date
|
|
32
|
-
min() {
|
|
33
|
-
return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'min' }));
|
|
34
|
-
}
|
|
35
|
-
max() {
|
|
36
|
-
return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'max' }));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
export default ComparableColumn;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import ComparableColumn from "./comparable-column";
|
|
2
|
-
import NumberColumn from "./number-column";
|
|
3
|
-
export default class DateColumn extends ComparableColumn {
|
|
4
|
-
constructor(table, name, modifiers = []) {
|
|
5
|
-
super(table, name, modifiers);
|
|
6
|
-
this._type = 'date';
|
|
7
|
-
}
|
|
8
|
-
count() {
|
|
9
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import ComparableColumn from "./comparable-column";
|
|
2
|
-
export default class NumberColumn extends ComparableColumn {
|
|
3
|
-
constructor(table, name, modifiers = []) {
|
|
4
|
-
super(table, name, modifiers);
|
|
5
|
-
this._type = 'number';
|
|
6
|
-
}
|
|
7
|
-
count() {
|
|
8
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
9
|
-
}
|
|
10
|
-
sum() {
|
|
11
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'sum' }));
|
|
12
|
-
}
|
|
13
|
-
avg() {
|
|
14
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'avg' }));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import QueryColumnCondition from "../condition/query-column-condition";
|
|
2
|
-
class QueryColumn {
|
|
3
|
-
constructor(_table, _name, _modifiers = []) {
|
|
4
|
-
this._table = _table;
|
|
5
|
-
this._name = _name;
|
|
6
|
-
this._modifiers = _modifiers;
|
|
7
|
-
}
|
|
8
|
-
as(alias) {
|
|
9
|
-
return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'as', params: alias }));
|
|
10
|
-
}
|
|
11
|
-
isNull() {
|
|
12
|
-
return new QueryColumnCondition(this, 'is-null');
|
|
13
|
-
}
|
|
14
|
-
isNotNull() {
|
|
15
|
-
return new QueryColumnCondition(this, 'is-not-null');
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export default QueryColumn;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import ComparableColumn from "./comparable-column";
|
|
2
|
-
import NumberColumn from "./number-column";
|
|
3
|
-
import QueryColumnCondition from "../condition/query-column-condition";
|
|
4
|
-
export default class StringColumn extends ComparableColumn {
|
|
5
|
-
constructor(table, name, modifiers = []) {
|
|
6
|
-
super(table, name, modifiers);
|
|
7
|
-
this._type = 'string';
|
|
8
|
-
}
|
|
9
|
-
count() {
|
|
10
|
-
return new NumberColumn(this._table, this._name, this._modifiers.concat({ name: 'count' }));
|
|
11
|
-
}
|
|
12
|
-
lower() {
|
|
13
|
-
return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'lower' }));
|
|
14
|
-
}
|
|
15
|
-
upper() {
|
|
16
|
-
return new this.constructor(this._table, this._name, this._modifiers.concat({ name: 'upper' }));
|
|
17
|
-
}
|
|
18
|
-
contains(value) {
|
|
19
|
-
return this.like('%' + value + '%');
|
|
20
|
-
}
|
|
21
|
-
startsWith(value) {
|
|
22
|
-
return this.like(value + '%');
|
|
23
|
-
}
|
|
24
|
-
endsWith(value) {
|
|
25
|
-
return this.like('%' + value);
|
|
26
|
-
}
|
|
27
|
-
like(value) {
|
|
28
|
-
return new QueryColumnCondition(this, 'like', value);
|
|
29
|
-
}
|
|
30
|
-
notLike(value) {
|
|
31
|
-
return new QueryColumnCondition(this, 'not-like', value);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import QueryColumnCondition from "../condition/query-column-condition";
|
|
2
|
-
import QueryOrdering from "../other/query-ordering";
|
|
3
|
-
import QueryColumn from "./query-column";
|
|
4
|
-
import QueryJoinCondition from "../condition/query-join-condition";
|
|
5
|
-
class ValueColumn extends QueryColumn {
|
|
6
|
-
constructor(table, name, modifiers = []) {
|
|
7
|
-
super(table, name, modifiers);
|
|
8
|
-
}
|
|
9
|
-
asc() {
|
|
10
|
-
return new QueryOrdering(this, 'ASC');
|
|
11
|
-
}
|
|
12
|
-
desc() {
|
|
13
|
-
return new QueryOrdering(this, 'DESC');
|
|
14
|
-
}
|
|
15
|
-
eq(value) {
|
|
16
|
-
if (value instanceof QueryColumn) {
|
|
17
|
-
return new QueryJoinCondition(this, 'eq', value);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return new QueryColumnCondition(this, 'eq', value);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
ne(value) {
|
|
24
|
-
return new QueryColumnCondition(this, 'ne', value);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
export default ValueColumn;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import QueryCondition from "./query-condition";
|
|
2
|
-
import QueryConditionChain from "./query-condition-chain";
|
|
3
|
-
export default class QueryColumnCondition extends QueryCondition {
|
|
4
|
-
constructor(column, type, ...values) {
|
|
5
|
-
super();
|
|
6
|
-
this._column = column;
|
|
7
|
-
this._type = type;
|
|
8
|
-
this._values = values;
|
|
9
|
-
}
|
|
10
|
-
and(condition) {
|
|
11
|
-
return new QueryConditionChain(this, condition, 'and');
|
|
12
|
-
}
|
|
13
|
-
or(condition) {
|
|
14
|
-
return new QueryConditionChain(this, condition, 'or');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import QueryCondition from "./query-condition";
|
|
2
|
-
export default class QueryConditionChain extends QueryCondition {
|
|
3
|
-
constructor(sibling, child, chainType) {
|
|
4
|
-
super();
|
|
5
|
-
this._parenthesis = false;
|
|
6
|
-
this._negation = false;
|
|
7
|
-
this._sibling = sibling;
|
|
8
|
-
this._child = child;
|
|
9
|
-
this._chainType = chainType;
|
|
10
|
-
}
|
|
11
|
-
// TODO how to call this
|
|
12
|
-
$() {
|
|
13
|
-
this._parenthesis = true;
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
not() {
|
|
17
|
-
this._negation = true;
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
and(condition) {
|
|
21
|
-
return new QueryConditionChain(this, condition, 'and');
|
|
22
|
-
}
|
|
23
|
-
or(condition) {
|
|
24
|
-
return new QueryConditionChain(this, condition, 'or');
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import QueryCondition from "./query-condition";
|
|
2
|
-
import QueryConditionChain from "./query-condition-chain";
|
|
3
|
-
export default class QueryJoinCondition extends QueryCondition {
|
|
4
|
-
constructor(column, type, otherColumn) {
|
|
5
|
-
super();
|
|
6
|
-
this._column = column;
|
|
7
|
-
this._type = type;
|
|
8
|
-
this._otherColumn = otherColumn;
|
|
9
|
-
}
|
|
10
|
-
and(condition) {
|
|
11
|
-
return new QueryConditionChain(this, condition, 'and');
|
|
12
|
-
}
|
|
13
|
-
or(condition) {
|
|
14
|
-
return new QueryConditionChain(this, condition, 'or');
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import JoinedTables from "./joined-tables";
|
|
2
|
-
export default class JoinedTablesChain {
|
|
3
|
-
constructor(_table, _modifier, _parent) {
|
|
4
|
-
this._table = _table;
|
|
5
|
-
this._modifier = _modifier;
|
|
6
|
-
this._parent = _parent;
|
|
7
|
-
}
|
|
8
|
-
on(condition) {
|
|
9
|
-
return new JoinedTables(condition, this);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import JoinedTablesChain from "./joined-tables-chain";
|
|
2
|
-
export default class JoinedTables {
|
|
3
|
-
constructor(_condition, _parent) {
|
|
4
|
-
this._condition = _condition;
|
|
5
|
-
this._parent = _parent;
|
|
6
|
-
}
|
|
7
|
-
innerJoin(table) {
|
|
8
|
-
return new JoinedTablesChain(table, 'inner', this);
|
|
9
|
-
}
|
|
10
|
-
leftJoin(table) {
|
|
11
|
-
return new JoinedTablesChain(table, 'left', this);
|
|
12
|
-
}
|
|
13
|
-
rightJoin(table) {
|
|
14
|
-
return new JoinedTablesChain(table, 'right', this);
|
|
15
|
-
}
|
|
16
|
-
fullJoin(table) {
|
|
17
|
-
return new JoinedTablesChain(table, 'full', this);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default class QueryOrdering {
|
|
2
|
-
constructor(column, direction) {
|
|
3
|
-
this._column = column;
|
|
4
|
-
this._direction = direction;
|
|
5
|
-
}
|
|
6
|
-
nullsFirst() {
|
|
7
|
-
this._nullsPosition = 'FIRST';
|
|
8
|
-
return this;
|
|
9
|
-
}
|
|
10
|
-
nullsLast() {
|
|
11
|
-
this._nullsPosition = 'LAST';
|
|
12
|
-
return this;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
export default class SelectQuery {
|
|
2
|
-
constructor(_queryProcessor, _tables) {
|
|
3
|
-
this._queryProcessor = _queryProcessor;
|
|
4
|
-
this._tables = _tables;
|
|
5
|
-
this._distinct = false;
|
|
6
|
-
this._conditions = [];
|
|
7
|
-
this._groupBy = [];
|
|
8
|
-
this._having = [];
|
|
9
|
-
this._orderings = [];
|
|
10
|
-
this._columns = [];
|
|
11
|
-
}
|
|
12
|
-
offset(offset) {
|
|
13
|
-
this._offset = offset;
|
|
14
|
-
return this;
|
|
15
|
-
}
|
|
16
|
-
limit(limit) {
|
|
17
|
-
this._limit = limit;
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
distinct() {
|
|
21
|
-
this._distinct = true;
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
where(...conditions) {
|
|
25
|
-
this._conditions = conditions;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
groupBy(...columns) {
|
|
29
|
-
this._groupBy = columns;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
having(...conditions) {
|
|
33
|
-
this._having = conditions;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
orderBy(...orderings) {
|
|
37
|
-
this._orderings = orderings;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
select(...columns) {
|
|
41
|
-
this._columns = columns;
|
|
42
|
-
this._action = 'select';
|
|
43
|
-
return this._queryProcessor(this);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export default class TableConditionQuery {
|
|
2
|
-
constructor(_queryProcessor, _table, _conditions) {
|
|
3
|
-
this._queryProcessor = _queryProcessor;
|
|
4
|
-
this._table = _table;
|
|
5
|
-
this._conditions = _conditions;
|
|
6
|
-
this._columns = [];
|
|
7
|
-
}
|
|
8
|
-
update(entity) {
|
|
9
|
-
this._entity = entity;
|
|
10
|
-
this._action = 'update';
|
|
11
|
-
return this._queryProcessor(this);
|
|
12
|
-
}
|
|
13
|
-
delete() {
|
|
14
|
-
this._action = 'delete';
|
|
15
|
-
return this._queryProcessor(this);
|
|
16
|
-
}
|
|
17
|
-
count() {
|
|
18
|
-
this._columns = [this._table.$all.count()];
|
|
19
|
-
this._action = 'select';
|
|
20
|
-
return this._queryProcessor(this).then((rows) => rows[0]);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import TableConditionQuery from "./table-condition-query";
|
|
2
|
-
import ValueColumn from "../column/value-column";
|
|
3
|
-
export default class TableQuery {
|
|
4
|
-
constructor(_queryProcessor, _table) {
|
|
5
|
-
this._queryProcessor = _queryProcessor;
|
|
6
|
-
this._table = _table;
|
|
7
|
-
this._columns = [];
|
|
8
|
-
}
|
|
9
|
-
where(...conditions) {
|
|
10
|
-
return new TableConditionQuery(this._queryProcessor, this._table, conditions);
|
|
11
|
-
}
|
|
12
|
-
insert(param) {
|
|
13
|
-
this._entity = param;
|
|
14
|
-
this._action = 'insert';
|
|
15
|
-
return this._queryProcessor(this);
|
|
16
|
-
}
|
|
17
|
-
deleteAll() {
|
|
18
|
-
this._action = 'delete';
|
|
19
|
-
return this._queryProcessor(this);
|
|
20
|
-
}
|
|
21
|
-
updateAll(entity) {
|
|
22
|
-
this._entity = entity;
|
|
23
|
-
this._action = 'update';
|
|
24
|
-
return this._queryProcessor(this);
|
|
25
|
-
}
|
|
26
|
-
countAll() {
|
|
27
|
-
this._columns = [this._table.$all.count()];
|
|
28
|
-
this._action = 'select';
|
|
29
|
-
return this._queryProcessor(this).then((rows) => rows[0]);
|
|
30
|
-
}
|
|
31
|
-
delete(id) {
|
|
32
|
-
return this._whereId(id).delete().then(count => count > 0);
|
|
33
|
-
}
|
|
34
|
-
update(id, entity) {
|
|
35
|
-
return this._whereId(id).update(entity).then(count => count > 0);
|
|
36
|
-
}
|
|
37
|
-
get(id) {
|
|
38
|
-
let query = this._whereId(id);
|
|
39
|
-
return this._queryProcessor({ _action: 'select', ...query })
|
|
40
|
-
.then((rows) => rows[0]);
|
|
41
|
-
}
|
|
42
|
-
_whereId(id) {
|
|
43
|
-
// TODO remove assertions if $id typing is fixed
|
|
44
|
-
let $id = this._table.$id;
|
|
45
|
-
if ($id instanceof ValueColumn) {
|
|
46
|
-
return this.where($id.eq(id));
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
return this.where(...Object.keys($id).map(key => this._table[key].eq(id[key])));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import SelectQuery from './query/select-query';
|
|
2
|
-
import TableQuery from "./query/table-query";
|
|
3
|
-
export default class QuerySource {
|
|
4
|
-
constructor(_queryProcessor) {
|
|
5
|
-
this._queryProcessor = _queryProcessor;
|
|
6
|
-
}
|
|
7
|
-
from(table1, table2, table3) {
|
|
8
|
-
if (table3 != null)
|
|
9
|
-
return new SelectQuery(this._queryProcessor, [table1, table2, table3]);
|
|
10
|
-
else if (table2 != null)
|
|
11
|
-
return new SelectQuery(this._queryProcessor, [table1, table2]);
|
|
12
|
-
return new SelectQuery(this._queryProcessor, [table1]);
|
|
13
|
-
}
|
|
14
|
-
table(table) {
|
|
15
|
-
return new TableQuery(this._queryProcessor, table);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import BasicColumn from "./column/basic-column";
|
|
2
|
-
import JoinedTablesChain from "./join/joined-tables-chain";
|
|
3
|
-
class QueryTable {
|
|
4
|
-
constructor(_$name) {
|
|
5
|
-
this._$name = _$name;
|
|
6
|
-
// abstract readonly $id; // FIXME I got a dozen incomprehensible type errors
|
|
7
|
-
this.$all = new BasicColumn(this, '*');
|
|
8
|
-
}
|
|
9
|
-
innerJoin(table) {
|
|
10
|
-
return new JoinedTablesChain(table, 'inner', this);
|
|
11
|
-
}
|
|
12
|
-
leftJoin(table) {
|
|
13
|
-
return new JoinedTablesChain(table, 'left', this);
|
|
14
|
-
}
|
|
15
|
-
rightJoin(table) {
|
|
16
|
-
return new JoinedTablesChain(table, 'right', this);
|
|
17
|
-
}
|
|
18
|
-
fullJoin(table) {
|
|
19
|
-
return new JoinedTablesChain(table, 'full', this);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export default QueryTable;
|
package/lib-prod/client/mysql.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import QuerySource from "../builder/query-source";
|
|
2
|
-
import { createQueryProcessor } from "./query-processor";
|
|
3
|
-
export default class MySqlQuerySource extends QuerySource {
|
|
4
|
-
constructor(client, options = {}) {
|
|
5
|
-
super(createQueryProcessor(client, options, 'mysql'));
|
|
6
|
-
}
|
|
7
|
-
}
|
package/lib-prod/client/pg.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import QuerySource from "../builder/query-source";
|
|
2
|
-
import { createQueryProcessor } from "./query-processor";
|
|
3
|
-
export default class PgQuerySource extends QuerySource {
|
|
4
|
-
constructor(client, options = {}) {
|
|
5
|
-
super(createQueryProcessor(client, options, 'pg'));
|
|
6
|
-
}
|
|
7
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { Log } from 'ng2-logger/lib-prod';
|
|
2
|
-
import { convertQueryToParameterizedSQL } from '../converter/parameterized-converter';
|
|
3
|
-
import { convertQueryToSQL } from '../converter/sql-converter';
|
|
4
|
-
const log = Log.create('query processor');
|
|
5
|
-
const DEFAULT_OPTIONS = {
|
|
6
|
-
lineBreaks: false,
|
|
7
|
-
parameterized: true,
|
|
8
|
-
logging: true,
|
|
9
|
-
identifierQuote: '"'
|
|
10
|
-
};
|
|
11
|
-
function mySqlTypeCast(field, next) {
|
|
12
|
-
if (field.type == 'TINY' && field.length == 1) { // Boolean
|
|
13
|
-
let value = field.string();
|
|
14
|
-
if (value == '1')
|
|
15
|
-
return true;
|
|
16
|
-
if (value == '0')
|
|
17
|
-
return false;
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
else if (field.type == 'JSON') {
|
|
21
|
-
let value = field.string();
|
|
22
|
-
return value == null ? null : JSON.parse(value);
|
|
23
|
-
}
|
|
24
|
-
return next();
|
|
25
|
-
}
|
|
26
|
-
export function createQueryProcessor(client, _options = {}, engine = 'pg') {
|
|
27
|
-
let options = Object.assign({}, DEFAULT_OPTIONS, _options);
|
|
28
|
-
let queryOptions = {
|
|
29
|
-
lineBreak: options.lineBreaks ? '\n' : ' ',
|
|
30
|
-
nameEscape: _options.identifierQuote || (engine === 'mysql' ? '`' : '"')
|
|
31
|
-
};
|
|
32
|
-
// function processSql(query: any, sql: string, params: any[] | undefined, callback: any): Promise<any> {
|
|
33
|
-
// if (options.logging) log.i(sql);
|
|
34
|
-
// if (options.logger) options.logger(sql, params);
|
|
35
|
-
// return new Promise((resolve, reject) => {
|
|
36
|
-
// callback(sql, params, (err: any, result: any) => {
|
|
37
|
-
// if (err) reject(err);
|
|
38
|
-
// else resolve(convertResult(query, result, engine));
|
|
39
|
-
// });
|
|
40
|
-
// });
|
|
41
|
-
// }
|
|
42
|
-
// function executeSql(sql: string, params: any[] | undefined, cb: any) {
|
|
43
|
-
// if (engine === 'pg') {
|
|
44
|
-
// client.query(sql, params || cb, params ? cb : undefined);
|
|
45
|
-
// } else if (engine === 'mysql') {
|
|
46
|
-
// client.query({
|
|
47
|
-
// sql,
|
|
48
|
-
// values: params,
|
|
49
|
-
// typeCast: mySqlTypeCast
|
|
50
|
-
// }, cb);
|
|
51
|
-
// } else throw new Error('Unknown DB engine: ' + engine);
|
|
52
|
-
// }
|
|
53
|
-
return (query) => {
|
|
54
|
-
if (options.parameterized) {
|
|
55
|
-
let { sql, params } = convertQueryToParameterizedSQL(query, queryOptions, engine);
|
|
56
|
-
// if (Helpers.isWebSQL || Helpers.isNode) {
|
|
57
|
-
return client.query(sql, params);
|
|
58
|
-
// }
|
|
59
|
-
// return processSql(query, sql, params, (sql: string, params: any[], cb: any) => executeSql(sql, params, cb));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
let sql = convertQueryToSQL(query, queryOptions, engine);
|
|
63
|
-
// if (Helpers.isWebSQL || Helpers.isNode) {
|
|
64
|
-
return client.query(sql, undefined);
|
|
65
|
-
// }
|
|
66
|
-
// return processSql(query, sql, undefined, (sql: string, params: undefined, cb: any) => executeSql(sql, undefined, cb));
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|