@sqb/connect 4.25.0 → 4.26.1
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { And, Count, Select } from '@sqb/builder';
|
|
1
|
+
import { And, Count, Select, TableName } from '@sqb/builder';
|
|
2
2
|
import { prepareFilter } from './command.helper.js';
|
|
3
3
|
export class CountCommand {
|
|
4
4
|
// istanbul ignore next
|
|
@@ -12,25 +12,17 @@ export class CountCommand {
|
|
|
12
12
|
where = And();
|
|
13
13
|
await prepareFilter(entity, filter, where, 'T');
|
|
14
14
|
}
|
|
15
|
-
const query = Select(Count()).from(
|
|
15
|
+
const query = Select(Count()).from(TableName({
|
|
16
|
+
table: entity.tableName,
|
|
17
|
+
alias: 'T',
|
|
18
|
+
optimizerHint: args.optimizerHint,
|
|
19
|
+
}));
|
|
16
20
|
if (args.comment) {
|
|
17
21
|
if (Array.isArray(args.comment))
|
|
18
22
|
args.comment.forEach(c => query.comment(c));
|
|
19
23
|
else
|
|
20
24
|
query.comment(args.comment);
|
|
21
25
|
}
|
|
22
|
-
if (args.indexHint) {
|
|
23
|
-
if (Array.isArray(args.indexHint))
|
|
24
|
-
args.indexHint.forEach(c => query.indexHint(c));
|
|
25
|
-
else
|
|
26
|
-
query.indexHint(args.indexHint);
|
|
27
|
-
}
|
|
28
|
-
if (args.noIndexHint) {
|
|
29
|
-
if (Array.isArray(args.noIndexHint))
|
|
30
|
-
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
31
|
-
else
|
|
32
|
-
query.noIndexHint(args.noIndexHint);
|
|
33
|
-
}
|
|
34
26
|
if (where)
|
|
35
27
|
query.where(where);
|
|
36
28
|
// Execute query
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { And, Delete } from '@sqb/builder';
|
|
1
|
+
import { And, Delete, TableName } from '@sqb/builder';
|
|
2
2
|
import { prepareFilter } from './command.helper.js';
|
|
3
3
|
export class DeleteCommand {
|
|
4
4
|
// istanbul ignore next
|
|
@@ -12,25 +12,17 @@ export class DeleteCommand {
|
|
|
12
12
|
where = And();
|
|
13
13
|
await prepareFilter(entity, filter, where);
|
|
14
14
|
}
|
|
15
|
-
const query = Delete(
|
|
15
|
+
const query = Delete(TableName({
|
|
16
|
+
table: entity.tableName,
|
|
17
|
+
alias: 'T',
|
|
18
|
+
optimizerHint: args.optimizerHint,
|
|
19
|
+
}));
|
|
16
20
|
if (args.comment) {
|
|
17
21
|
if (Array.isArray(args.comment))
|
|
18
22
|
args.comment.forEach(c => query.comment(c));
|
|
19
23
|
else
|
|
20
24
|
query.comment(args.comment);
|
|
21
25
|
}
|
|
22
|
-
if (args.indexHint) {
|
|
23
|
-
if (Array.isArray(args.indexHint))
|
|
24
|
-
args.indexHint.forEach(c => query.indexHint(c));
|
|
25
|
-
else
|
|
26
|
-
query.indexHint(args.indexHint);
|
|
27
|
-
}
|
|
28
|
-
if (args.noIndexHint) {
|
|
29
|
-
if (Array.isArray(args.noIndexHint))
|
|
30
|
-
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
31
|
-
else
|
|
32
|
-
query.noIndexHint(args.noIndexHint);
|
|
33
|
-
}
|
|
34
26
|
if (where)
|
|
35
27
|
query.where(...where._items);
|
|
36
28
|
// Execute query
|
|
@@ -38,6 +38,6 @@ export declare class FindCommand {
|
|
|
38
38
|
private _selectColumn;
|
|
39
39
|
filter(filter: any): Promise<void>;
|
|
40
40
|
sort(sortFields: string[]): Promise<void>;
|
|
41
|
-
execute(args: Pick<FindCommandArgs, 'connection' | 'distinct' | 'offset' | 'limit' | 'params' | 'onTransformRow' | 'prettyPrint' | 'comment' | '
|
|
41
|
+
execute(args: Pick<FindCommandArgs, 'connection' | 'distinct' | 'offset' | 'limit' | 'params' | 'onTransformRow' | 'prettyPrint' | 'comment' | 'optimizerHint'>): Promise<any[]>;
|
|
42
42
|
private _getEntityFromAlias;
|
|
43
43
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { And, In, Param, Select } from '@sqb/builder';
|
|
1
|
+
import { And, In, Param, Select, TableName } from '@sqb/builder';
|
|
2
2
|
import { AssociationNode } from '../model/association-node.js';
|
|
3
3
|
import { EntityMetadata } from '../model/entity-metadata.js';
|
|
4
4
|
import { isAssociationField, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
@@ -241,25 +241,17 @@ export class FindCommand {
|
|
|
241
241
|
const columnSqls = Object.keys(this._selectColumns).map(x => this._selectColumns[x].statement);
|
|
242
242
|
if (!columnSqls.length)
|
|
243
243
|
columnSqls.push('1');
|
|
244
|
-
const query = Select(...columnSqls).from(
|
|
244
|
+
const query = Select(...columnSqls).from(TableName({
|
|
245
|
+
table: this.mainEntity.tableName,
|
|
246
|
+
alias: this.mainAlias,
|
|
247
|
+
optimizerHint: args.optimizerHint,
|
|
248
|
+
}));
|
|
245
249
|
if (args.comment) {
|
|
246
250
|
if (Array.isArray(args.comment))
|
|
247
251
|
args.comment.forEach(c => query.comment(c));
|
|
248
252
|
else
|
|
249
253
|
query.comment(args.comment);
|
|
250
254
|
}
|
|
251
|
-
if (args.indexHint) {
|
|
252
|
-
if (Array.isArray(args.indexHint))
|
|
253
|
-
args.indexHint.forEach(c => query.indexHint(c));
|
|
254
|
-
else
|
|
255
|
-
query.indexHint(args.indexHint);
|
|
256
|
-
}
|
|
257
|
-
if (args.noIndexHint) {
|
|
258
|
-
if (Array.isArray(args.noIndexHint))
|
|
259
|
-
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
260
|
-
else
|
|
261
|
-
query.noIndexHint(args.noIndexHint);
|
|
262
|
-
}
|
|
263
255
|
if (args.distinct)
|
|
264
256
|
query.distinct();
|
|
265
257
|
query.where(...this._filter._items);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { And, Param, Update } from '@sqb/builder';
|
|
1
|
+
import { And, Param, TableName, Update } from '@sqb/builder';
|
|
2
2
|
import { checkEnumValue, isColumnField, isEmbeddedField, resolveEntityForEmbeddedField, } from '../util/orm.helper.js';
|
|
3
3
|
import { prepareFilter } from './command.helper.js';
|
|
4
4
|
export class UpdateCommand {
|
|
@@ -25,25 +25,17 @@ export class UpdateCommand {
|
|
|
25
25
|
return 0;
|
|
26
26
|
if (args.filter)
|
|
27
27
|
await this._prepareFilter(ctx, args.filter);
|
|
28
|
-
const query = Update(
|
|
28
|
+
const query = Update(TableName({
|
|
29
|
+
table: tableName,
|
|
30
|
+
alias: 'T',
|
|
31
|
+
optimizerHint: args.optimizerHint,
|
|
32
|
+
}), ctx.queryValues).where(...ctx.queryFilter);
|
|
29
33
|
if (args.comment) {
|
|
30
34
|
if (Array.isArray(args.comment))
|
|
31
35
|
args.comment.forEach(c => query.comment(c));
|
|
32
36
|
else
|
|
33
37
|
query.comment(args.comment);
|
|
34
38
|
}
|
|
35
|
-
if (args.indexHint) {
|
|
36
|
-
if (Array.isArray(args.indexHint))
|
|
37
|
-
args.indexHint.forEach(c => query.indexHint(c));
|
|
38
|
-
else
|
|
39
|
-
query.indexHint(args.indexHint);
|
|
40
|
-
}
|
|
41
|
-
if (args.noIndexHint) {
|
|
42
|
-
if (Array.isArray(args.noIndexHint))
|
|
43
|
-
args.noIndexHint.forEach(c => query.noIndexHint(c));
|
|
44
|
-
else
|
|
45
|
-
query.noIndexHint(args.noIndexHint);
|
|
46
|
-
}
|
|
47
39
|
const qr = await args.connection.execute(query, {
|
|
48
40
|
params: args.params ? [...args.params, ctx.queryParams] : ctx.queryParams,
|
|
49
41
|
objectRows: false,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { LogicalOperator } from '@sqb/builder';
|
|
2
|
+
import { OptimizerHintArgs } from '@sqb/builder/build/sql-objects/table-name';
|
|
2
3
|
import { PartialDTO, PatchDTO, RequiredSome, StrictOmit, Type } from 'ts-gems';
|
|
3
4
|
import { FieldInfoMap } from '../client/field-info-map.js';
|
|
4
5
|
import type { SqbClient } from '../client/sqb-client.js';
|
|
@@ -24,20 +25,7 @@ export declare namespace Repository {
|
|
|
24
25
|
comment: string;
|
|
25
26
|
dialect?: string[];
|
|
26
27
|
}[];
|
|
27
|
-
|
|
28
|
-
index: string[];
|
|
29
|
-
dialect?: string[];
|
|
30
|
-
} | {
|
|
31
|
-
index: string[];
|
|
32
|
-
dialect?: string[];
|
|
33
|
-
}[];
|
|
34
|
-
noIndexHint?: string | string[] | {
|
|
35
|
-
index: string[];
|
|
36
|
-
dialect?: string[];
|
|
37
|
-
} | {
|
|
38
|
-
index: string[];
|
|
39
|
-
dialect?: string[];
|
|
40
|
-
}[];
|
|
28
|
+
optimizerHint?: string | string[] | OptimizerHintArgs | OptimizerHintArgs[];
|
|
41
29
|
}
|
|
42
30
|
interface CreateOptions extends CommandOptions, Projection {
|
|
43
31
|
}
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqb/connect",
|
|
3
3
|
"description": "Multi-dialect database connection framework written with TypeScript",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.26.1",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@jsopen/objects": "^2.2.
|
|
8
|
+
"@jsopen/objects": "^2.2.1",
|
|
9
9
|
"debug": "^4.4.3",
|
|
10
10
|
"doublylinked": "^2.5.6",
|
|
11
11
|
"fast-tokenizer": "^1.9.0",
|
|
12
12
|
"lightning-pool": "^4.12.0",
|
|
13
|
-
"lodash": "^4.
|
|
14
|
-
"power-tasks": "^1.
|
|
13
|
+
"lodash": "^4.18.1",
|
|
14
|
+
"power-tasks": "^1.14.2",
|
|
15
15
|
"putil-isplainobject": "^1.1.5",
|
|
16
16
|
"putil-merge": "^3.13.0",
|
|
17
17
|
"putil-promisify": "^1.10.1",
|
|
18
18
|
"putil-varhelpers": "^1.7.0",
|
|
19
19
|
"strict-typed-events": "^2.8.0",
|
|
20
|
-
"ts-gems": "^3.11.
|
|
20
|
+
"ts-gems": "^3.11.6",
|
|
21
21
|
"tslib": "^2.8.1"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@sqb/builder": "^4.
|
|
24
|
+
"@sqb/builder": "^4.26.1",
|
|
25
25
|
"reflect-metadata": "^0.2.2"
|
|
26
26
|
},
|
|
27
27
|
"type": "module",
|