@entity-access/entity-access 1.1.16 → 1.1.18
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/dist/compiler/postgres/PostgreSqlMethodTransformer.d.ts.map +1 -1
- package/dist/compiler/postgres/PostgreSqlMethodTransformer.js +13 -5
- package/dist/compiler/postgres/PostgreSqlMethodTransformer.js.map +1 -1
- package/dist/compiler/sql-server/SqlServerSqlMethodTransformer.d.ts.map +1 -1
- package/dist/compiler/sql-server/SqlServerSqlMethodTransformer.js +9 -3
- package/dist/compiler/sql-server/SqlServerSqlMethodTransformer.js.map +1 -1
- package/dist/migrations/Migrations.d.ts.map +1 -1
- package/dist/migrations/Migrations.js +18 -6
- package/dist/migrations/Migrations.js.map +1 -1
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.d.ts.map +1 -1
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.js +15 -3
- package/dist/migrations/sql-server/SqlServerAutomaticMigrations.js.map +1 -1
- package/dist/model/EntityModel.d.ts.map +1 -1
- package/dist/model/EntityModel.js +11 -0
- package/dist/model/EntityModel.js.map +1 -1
- package/dist/query/ast/IStringTransformer.d.ts +8 -0
- package/dist/query/ast/IStringTransformer.d.ts.map +1 -1
- package/dist/query/ast/IStringTransformer.js +22 -0
- package/dist/query/ast/IStringTransformer.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/compiler/postgres/PostgreSqlMethodTransformer.ts +13 -5
- package/src/compiler/sql-server/SqlServerSqlMethodTransformer.ts +9 -3
- package/src/migrations/Migrations.ts +19 -6
- package/src/migrations/sql-server/SqlServerAutomaticMigrations.ts +15 -3
- package/src/model/EntityModel.ts +11 -0
- package/src/query/ast/IStringTransformer.ts +31 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { joinAny, joinMap, prepareAny } from "../../query/ast/IStringTransformer.js";
|
|
2
|
+
import { expandParamArray, joinAny, joinMap, prepareAny } from "../../query/ast/IStringTransformer.js";
|
|
3
3
|
import Sql from "../../sql/Sql.js";
|
|
4
4
|
import { ISqlHelpers, flattenMethods } from "../ISqlHelpers.js";
|
|
5
5
|
|
|
@@ -281,8 +281,14 @@ export const SqlServerSqlHelper: ISqlHelpers = {
|
|
|
281
281
|
iLike(text, test) {
|
|
282
282
|
return prepareAny `(${text} like ${test})`;
|
|
283
283
|
},
|
|
284
|
-
iLikeAny(text,
|
|
285
|
-
return
|
|
284
|
+
iLikeAny(text, input) {
|
|
285
|
+
return expandParamArray({
|
|
286
|
+
input,
|
|
287
|
+
sep: " OR ",
|
|
288
|
+
prefix: ["("],
|
|
289
|
+
fx: (item) => ["(", text, " like ", () => item, ")" ] as any,
|
|
290
|
+
suffix: [")"]
|
|
291
|
+
});
|
|
286
292
|
},
|
|
287
293
|
indexOf(text, test) {
|
|
288
294
|
return prepareAny `(CHARINDEX(${test}, ${text}) - 1)`;
|
|
@@ -90,6 +90,17 @@ export default abstract class Migrations {
|
|
|
90
90
|
await this.enableGeoSpatialTypes();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
// for (const index of type.indexes) {
|
|
94
|
+
// for (const column of index.columns) {
|
|
95
|
+
// const c = type.getProperty(column.name);
|
|
96
|
+
// if (c.field) {
|
|
97
|
+
// column.name = c.field.columnName;
|
|
98
|
+
// } else {
|
|
99
|
+
// debugger;
|
|
100
|
+
// }
|
|
101
|
+
// }
|
|
102
|
+
// }
|
|
103
|
+
|
|
93
104
|
const schema = await this.getSchema(type);
|
|
94
105
|
|
|
95
106
|
await this.migrateTable(context, type);
|
|
@@ -217,12 +228,14 @@ export default abstract class Migrations {
|
|
|
217
228
|
}
|
|
218
229
|
|
|
219
230
|
|
|
220
|
-
for (const column of index.columns) {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
231
|
+
// for (const column of index.columns) {
|
|
232
|
+
// const c = type.getProperty(column.name);
|
|
233
|
+
// if (c.field) {
|
|
234
|
+
// column.name = c.field.columnName;
|
|
235
|
+
// } else {
|
|
236
|
+
// debugger;
|
|
237
|
+
// }
|
|
238
|
+
// }
|
|
226
239
|
|
|
227
240
|
if (index.include) {
|
|
228
241
|
index.include = index.include.map((c) => type.getProperty(c).field.columnName);
|
|
@@ -32,7 +32,7 @@ export default class SqlServerAutomaticMigrations extends SqlServerMigrations {
|
|
|
32
32
|
: "";
|
|
33
33
|
const indexDef: IIndex = {
|
|
34
34
|
name: `IX_${type.name}_${iterator.name}`,
|
|
35
|
-
columns: [{ name: iterator.
|
|
35
|
+
columns: [{ name: iterator.columnName, descending: iterator.indexOrder !== "ascending"}],
|
|
36
36
|
filter
|
|
37
37
|
};
|
|
38
38
|
await this.migrateIndexInternal(context, indexDef, type);
|
|
@@ -123,15 +123,27 @@ export default class SqlServerAutomaticMigrations extends SqlServerMigrations {
|
|
|
123
123
|
: type.name;
|
|
124
124
|
const indexName = index.name;
|
|
125
125
|
const columns = [];
|
|
126
|
-
let spatial =
|
|
126
|
+
let spatial = false;
|
|
127
|
+
let nonSpatial = false;
|
|
127
128
|
for (const column of index.columns) {
|
|
128
129
|
const columnName = column.name;
|
|
129
130
|
const c = type.getColumn(column.name);
|
|
130
131
|
const isColumnSpatial = isSpatialType(c.dataType);
|
|
131
|
-
|
|
132
|
+
if (isColumnSpatial) {
|
|
133
|
+
spatial ||= true;
|
|
134
|
+
} else {
|
|
135
|
+
nonSpatial ||= true;
|
|
136
|
+
}
|
|
132
137
|
columns.push(`${columnName} ${ isSpatialType(c.dataType) ? "" : (column.descending ? "DESC" : "ASC")}`);
|
|
133
138
|
}
|
|
134
139
|
|
|
140
|
+
if (spatial) {
|
|
141
|
+
if (nonSpatial) {
|
|
142
|
+
console.warn(`SQL SERVER DOEST NOT SUPPORT SPATIAL AND OTHER DATATYPE INDEX so ${name} index is not created`);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
135
147
|
const indexType = spatial ? " SPATIAL " : "";
|
|
136
148
|
|
|
137
149
|
let query = `IF NOT EXISTS(SELECT * FROM sys.indexes WHERE name = '${indexName}' AND object_id = OBJECT_ID('${name}'))
|
package/src/model/EntityModel.ts
CHANGED
|
@@ -44,6 +44,17 @@ const getOrCreateModel = (map: Map<any, EntityType>, type: IClassOf<any>, compil
|
|
|
44
44
|
if (t.keys.length > 1) {
|
|
45
45
|
t.keys.sort((a, b) => a.order - b.order);
|
|
46
46
|
}
|
|
47
|
+
|
|
48
|
+
for(const index of t.indexes) {
|
|
49
|
+
for (const column of index.columns) {
|
|
50
|
+
const c = t.getProperty(column.name);
|
|
51
|
+
if (c.field) {
|
|
52
|
+
column.name = c.field.columnName;
|
|
53
|
+
} else {
|
|
54
|
+
debugger;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
for (const iterator of original.relations) {
|
|
48
59
|
if (!iterator.relatedTypeClass) {
|
|
49
60
|
iterator.relatedTypeClass = iterator.relatedTypeClassFactory();
|
|
@@ -20,6 +20,37 @@ export class QueryParameter {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
export const expandParamArray = ({
|
|
24
|
+
sep = ",",
|
|
25
|
+
input,
|
|
26
|
+
prefix = [],
|
|
27
|
+
suffix = [],
|
|
28
|
+
emptyResult = [" false "],
|
|
29
|
+
fx = (xi) => [() => xi]
|
|
30
|
+
}) => [(p) => {
|
|
31
|
+
const a = input[0](p);
|
|
32
|
+
if (!a.length) {
|
|
33
|
+
return emptyResult;
|
|
34
|
+
}
|
|
35
|
+
const r = prefix;
|
|
36
|
+
let s = "";
|
|
37
|
+
for (const iterator of a) {
|
|
38
|
+
if (s) {
|
|
39
|
+
r.push(s);
|
|
40
|
+
}
|
|
41
|
+
s = sep;
|
|
42
|
+
const items = fx(iterator).flat(2);
|
|
43
|
+
for (const fi of items) {
|
|
44
|
+
r.push(fi);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
for(const sx of suffix) {
|
|
48
|
+
r.push(sx);
|
|
49
|
+
}
|
|
50
|
+
return r.flat(2);
|
|
51
|
+
}] as any;
|
|
52
|
+
|
|
53
|
+
|
|
23
54
|
export const joinMap = (sep: string, input, a: any, fx: ((item) => any) = (xi) => [() => xi]) => {
|
|
24
55
|
const r = [];
|
|
25
56
|
a = (Array.isArray(a) ? a.map((x) => x(input)) : a(input)).flat(2);
|