forge-sql-orm 2.0.28 → 2.0.29
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/ForgeSQLORM.js +19 -17
- package/dist/ForgeSQLORM.js.map +1 -1
- package/dist/ForgeSQLORM.mjs +19 -17
- package/dist/ForgeSQLORM.mjs.map +1 -1
- package/dist/core/ForgeSQLAnalyseOperations.d.ts.map +1 -1
- package/dist/utils/sqlUtils.d.ts +2 -2
- package/dist/utils/sqlUtils.d.ts.map +1 -1
- package/package.json +13 -7
- package/src/core/ForgeSQLAnalyseOperations.ts +3 -2
- package/src/core/ForgeSQLQueryBuilder.ts +8 -8
- package/src/utils/sqlUtils.ts +18 -10
package/dist/ForgeSQLORM.mjs
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { isTable, sql, eq, and } from "drizzle-orm";
|
|
2
|
-
import
|
|
2
|
+
import { DateTime } from "luxon";
|
|
3
3
|
import { isSQLWrapper } from "drizzle-orm/sql/sql";
|
|
4
4
|
import { sql as sql$1, migrationRunner } from "@forge/sql";
|
|
5
5
|
import { drizzle } from "drizzle-orm/mysql-proxy";
|
|
6
6
|
import { customType, mysqlTable, timestamp, varchar, bigint } from "drizzle-orm/mysql-core";
|
|
7
|
-
import moment$1 from "moment/moment.js";
|
|
8
7
|
import { getTableName } from "drizzle-orm/table";
|
|
9
8
|
const parseDateTime = (value, format) => {
|
|
10
9
|
let result;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
if (value instanceof Date) {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
const dt = DateTime.fromFormat(value, format);
|
|
14
|
+
if (dt.isValid) {
|
|
15
|
+
result = dt.toJSDate();
|
|
16
|
+
} else {
|
|
17
|
+
const isoDt = DateTime.fromISO(value);
|
|
18
|
+
if (isoDt.isValid) {
|
|
19
|
+
result = isoDt.toJSDate();
|
|
16
20
|
} else {
|
|
17
21
|
result = new Date(value);
|
|
18
22
|
}
|
|
19
|
-
} else {
|
|
20
|
-
result = m.toDate();
|
|
21
23
|
}
|
|
22
24
|
if (isNaN(result.getTime())) {
|
|
23
25
|
result = new Date(value);
|
|
@@ -908,7 +910,7 @@ class ForgeSQLAnalyseOperation {
|
|
|
908
910
|
* @returns {string} The SQL query for cluster statement history
|
|
909
911
|
*/
|
|
910
912
|
buildClusterStatementQuery(tables, from, to) {
|
|
911
|
-
const formatDateTime = (date) =>
|
|
913
|
+
const formatDateTime = (date) => DateTime.fromJSDate(date).toFormat("yyyy-LL-dd'T'HH:mm:ss.SSS");
|
|
912
914
|
const tableConditions = tables.map((table) => `TABLE_NAMES LIKE CONCAT(SCHEMA_NAME, '.', '%', '${table}', '%')`).join(" OR ");
|
|
913
915
|
const timeConditions = [];
|
|
914
916
|
if (from) {
|
|
@@ -1198,10 +1200,10 @@ const forgeDateTimeString = customType({
|
|
|
1198
1200
|
return "datetime";
|
|
1199
1201
|
},
|
|
1200
1202
|
toDriver(value) {
|
|
1201
|
-
return
|
|
1203
|
+
return DateTime.fromJSDate(value).toFormat("yyyy-LL-dd'T'HH:mm:ss.SSS");
|
|
1202
1204
|
},
|
|
1203
1205
|
fromDriver(value) {
|
|
1204
|
-
const format = "
|
|
1206
|
+
const format = "yyyy-LL-dd'T'HH:mm:ss.SSS";
|
|
1205
1207
|
return parseDateTime(value, format);
|
|
1206
1208
|
}
|
|
1207
1209
|
});
|
|
@@ -1210,10 +1212,10 @@ const forgeTimestampString = customType({
|
|
|
1210
1212
|
return "timestamp";
|
|
1211
1213
|
},
|
|
1212
1214
|
toDriver(value) {
|
|
1213
|
-
return
|
|
1215
|
+
return DateTime.fromJSDate(value).toFormat("yyyy-LL-dd'T'HH:mm:ss.SSS");
|
|
1214
1216
|
},
|
|
1215
1217
|
fromDriver(value) {
|
|
1216
|
-
const format = "
|
|
1218
|
+
const format = "yyyy-LL-dd'T'HH:mm:ss.SSS";
|
|
1217
1219
|
return parseDateTime(value, format);
|
|
1218
1220
|
}
|
|
1219
1221
|
});
|
|
@@ -1222,10 +1224,10 @@ const forgeDateString = customType({
|
|
|
1222
1224
|
return "date";
|
|
1223
1225
|
},
|
|
1224
1226
|
toDriver(value) {
|
|
1225
|
-
return
|
|
1227
|
+
return DateTime.fromJSDate(value).toFormat("yyyy-LL-dd");
|
|
1226
1228
|
},
|
|
1227
1229
|
fromDriver(value) {
|
|
1228
|
-
const format = "
|
|
1230
|
+
const format = "yyyy-LL-dd";
|
|
1229
1231
|
return parseDateTime(value, format);
|
|
1230
1232
|
}
|
|
1231
1233
|
});
|
|
@@ -1234,7 +1236,7 @@ const forgeTimeString = customType({
|
|
|
1234
1236
|
return "time";
|
|
1235
1237
|
},
|
|
1236
1238
|
toDriver(value) {
|
|
1237
|
-
return
|
|
1239
|
+
return DateTime.fromJSDate(value).toFormat("HH:mm:ss.SSS");
|
|
1238
1240
|
},
|
|
1239
1241
|
fromDriver(value) {
|
|
1240
1242
|
return parseDateTime(value, "HH:mm:ss.SSS");
|