baja-lite 1.3.23 → 1.3.25
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/code.js +25 -6
- package/package.json +1 -1
- package/sql.d.ts +11 -6
- package/sql.js +7 -3
package/code.js
CHANGED
|
@@ -12,7 +12,7 @@ const lxMap = {
|
|
|
12
12
|
mediumint: "number",
|
|
13
13
|
int: "number",
|
|
14
14
|
integer: "number",
|
|
15
|
-
bigint: "
|
|
15
|
+
bigint: "number",
|
|
16
16
|
bit: "boolean",
|
|
17
17
|
double: "number",
|
|
18
18
|
real: "number",
|
|
@@ -24,7 +24,7 @@ const lxMap = {
|
|
|
24
24
|
date: "Date",
|
|
25
25
|
time: "string",
|
|
26
26
|
year: "string",
|
|
27
|
-
timestamp: "
|
|
27
|
+
timestamp: "number",
|
|
28
28
|
datetime: "Date",
|
|
29
29
|
tinyblob: "string",
|
|
30
30
|
blob: "string",
|
|
@@ -185,6 +185,7 @@ try {
|
|
|
185
185
|
else
|
|
186
186
|
delete r.notNull;
|
|
187
187
|
const fields = new Array(`type:SqlType.${r.type}`);
|
|
188
|
+
r.Type = lxMap[r.type];
|
|
188
189
|
if (r.length !== null) {
|
|
189
190
|
fields.push(`length:${r.length}`);
|
|
190
191
|
}
|
|
@@ -193,13 +194,32 @@ try {
|
|
|
193
194
|
}
|
|
194
195
|
if (r.def !== null) {
|
|
195
196
|
r.def ?? (r.def = '');
|
|
196
|
-
if (
|
|
197
|
-
|
|
197
|
+
if (r.def !== '') {
|
|
198
|
+
if (isNaN(r.def)) {
|
|
199
|
+
fields.push(`def:'${r.def}'`);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
fields.push(`def:${r.def}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (r.Type === 'string') {
|
|
207
|
+
if (r.def === '' || r.def === null) {
|
|
208
|
+
r.def = "''";
|
|
198
209
|
}
|
|
199
210
|
else {
|
|
200
|
-
|
|
211
|
+
r.def = `'${r.def}'`;
|
|
201
212
|
}
|
|
202
213
|
}
|
|
214
|
+
else if (r.Type === 'number') {
|
|
215
|
+
r.def = 0;
|
|
216
|
+
}
|
|
217
|
+
else if (r.Type === 'Date') {
|
|
218
|
+
r.def = 'new Date()';
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
r.def = 'null';
|
|
222
|
+
}
|
|
203
223
|
if (r.id === true) {
|
|
204
224
|
fields.push(`id:true`);
|
|
205
225
|
}
|
|
@@ -217,7 +237,6 @@ try {
|
|
|
217
237
|
fields.push(`comment: '${r.comment}'`);
|
|
218
238
|
}
|
|
219
239
|
r.comment = r.comment ?? '';
|
|
220
|
-
r.Type = lxMap[r.type];
|
|
221
240
|
r.Field = `@Field({${fields.join(',')}})`;
|
|
222
241
|
r.Name = r.name.replace(/_(\w)/g, (a, b) => b.toUpperCase());
|
|
223
242
|
r.NAME = r.Name.replace(/\w/, (v) => v.toUpperCase());
|
package/package.json
CHANGED
package/sql.d.ts
CHANGED
|
@@ -372,7 +372,7 @@ export interface GlobalSqlOption extends GlobalSqlOptionForWeb {
|
|
|
372
372
|
isSum?: boolean;
|
|
373
373
|
limitStart?: number;
|
|
374
374
|
limitEnd?: number;
|
|
375
|
-
|
|
375
|
+
sortName?: string; sortType?: string;
|
|
376
376
|
params?: Record<string, any>;
|
|
377
377
|
}) => {
|
|
378
378
|
return `
|
|
@@ -605,7 +605,8 @@ export type SqlModel = Record<string, string | ((options: {
|
|
|
605
605
|
isSum?: boolean;
|
|
606
606
|
limitStart?: number;
|
|
607
607
|
limitEnd?: number;
|
|
608
|
-
|
|
608
|
+
sortName?: string;
|
|
609
|
+
sortType?: string;
|
|
609
610
|
params?: any;
|
|
610
611
|
}) => string)>;
|
|
611
612
|
type _SqlModel = Record<string, string | ((options: {
|
|
@@ -614,7 +615,8 @@ type _SqlModel = Record<string, string | ((options: {
|
|
|
614
615
|
isSum?: boolean;
|
|
615
616
|
limitStart?: number;
|
|
616
617
|
limitEnd?: number;
|
|
617
|
-
|
|
618
|
+
sortName?: string;
|
|
619
|
+
sortType?: string;
|
|
618
620
|
params?: any;
|
|
619
621
|
}) => string) | XML[]>;
|
|
620
622
|
/**
|
|
@@ -657,7 +659,8 @@ export declare class SqlCache {
|
|
|
657
659
|
isSum?: boolean;
|
|
658
660
|
limitStart?: number;
|
|
659
661
|
limitEnd?: number;
|
|
660
|
-
|
|
662
|
+
sortName?: string;
|
|
663
|
+
sortType?: string;
|
|
661
664
|
[k: string]: any;
|
|
662
665
|
}): string;
|
|
663
666
|
}
|
|
@@ -1261,7 +1264,8 @@ export declare class SqlService<T extends object> {
|
|
|
1261
1264
|
limitSelf?: boolean;
|
|
1262
1265
|
countSelf?: boolean;
|
|
1263
1266
|
sumSelf?: boolean;
|
|
1264
|
-
|
|
1267
|
+
sortName?: string;
|
|
1268
|
+
sortType?: string;
|
|
1265
1269
|
hump?: boolean;
|
|
1266
1270
|
mapper?: string | SqlMapper;
|
|
1267
1271
|
mapperIfUndefined?: MapperIfUndefined;
|
|
@@ -1276,7 +1280,8 @@ export declare class SqlService<T extends object> {
|
|
|
1276
1280
|
limitSelf?: boolean;
|
|
1277
1281
|
countSelf?: boolean;
|
|
1278
1282
|
sumSelf?: boolean;
|
|
1279
|
-
|
|
1283
|
+
sortName?: string;
|
|
1284
|
+
sortType?: string;
|
|
1280
1285
|
hump?: boolean;
|
|
1281
1286
|
mapper?: string | SqlMapper;
|
|
1282
1287
|
mapperIfUndefined?: MapperIfUndefined;
|
package/sql.js
CHANGED
|
@@ -1208,7 +1208,7 @@ class Build {
|
|
|
1208
1208
|
constructor(isCount, isSum, param = {}) {
|
|
1209
1209
|
this.isCount = isCount;
|
|
1210
1210
|
this.isSum = isSum;
|
|
1211
|
-
this.orderBy = param.
|
|
1211
|
+
this.orderBy = param.sortName ? `${param.sortName} ${param.sortType ?? 'ASC'}` : '';
|
|
1212
1212
|
Object.assign(this, param);
|
|
1213
1213
|
}
|
|
1214
1214
|
/**
|
|
@@ -2842,10 +2842,14 @@ export class SqlService {
|
|
|
2842
2842
|
};
|
|
2843
2843
|
option.pageNumber ?? (option.pageNumber = 1);
|
|
2844
2844
|
option.pageSize ?? (option.pageSize = 0);
|
|
2845
|
+
if (option.hump === true || (option.hump === undefined && globalThis[_Hump] === true) && option.sortName) {
|
|
2846
|
+
option.sortName = P2C(option.sortName);
|
|
2847
|
+
}
|
|
2845
2848
|
Object.assign(option.params, {
|
|
2846
2849
|
limitStart: calc(option.pageNumber).sub(1).mul(option.pageSize).over(),
|
|
2847
|
-
limitEnd:
|
|
2848
|
-
|
|
2850
|
+
limitEnd: option.pageSize - 0,
|
|
2851
|
+
sortName: option.sortName ?? undefined,
|
|
2852
|
+
sortType: option.sortType ?? undefined
|
|
2849
2853
|
});
|
|
2850
2854
|
let sql = globalThis[_sqlCache].load(this._matchSqlid(option.sqlId), { ctx: option.context, isCount: false, ...option.params });
|
|
2851
2855
|
let sqlSum = '';
|