@sqg/sqg 0.2.1 → 0.2.2
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/sqg.mjs +7 -2
- package/dist/templates/java-jdbc.hbs +12 -0
- package/package.json +1 -1
package/dist/sqg.mjs
CHANGED
|
@@ -1049,7 +1049,12 @@ var JavaTypeMapper = class JavaTypeMapper extends TypeMapper {
|
|
|
1049
1049
|
return `arrayToList((Array)${value}, ${elementType}[].class)`;
|
|
1050
1050
|
}
|
|
1051
1051
|
if (column.type instanceof StructType) return `${path}${this.formatStructTypeName(column.name)}.fromAttributes(getAttr((Struct)${value}))`;
|
|
1052
|
-
|
|
1052
|
+
const fieldType = this.getTypeName(column);
|
|
1053
|
+
const upperType = column.type?.toString().toUpperCase() ?? "";
|
|
1054
|
+
if (upperType === "TIMESTAMP" || upperType === "DATETIME") return `toLocalDateTime((java.sql.Timestamp)${value})`;
|
|
1055
|
+
if (upperType === "DATE") return `toLocalDate((java.sql.Date)${value})`;
|
|
1056
|
+
if (upperType === "TIME") return `toLocalTime((java.sql.Time)${value})`;
|
|
1057
|
+
return `(${fieldType})${value}`;
|
|
1053
1058
|
}
|
|
1054
1059
|
getInnermostType(type) {
|
|
1055
1060
|
let current = type.baseType;
|
|
@@ -2237,7 +2242,7 @@ Documentation: https://sqg.dev
|
|
|
2237
2242
|
|
|
2238
2243
|
//#endregion
|
|
2239
2244
|
//#region src/sqg.ts
|
|
2240
|
-
const version = process.env.npm_package_version ?? "0.2.
|
|
2245
|
+
const version = process.env.npm_package_version ?? "0.2.2";
|
|
2241
2246
|
const description = process.env.npm_package_description ?? "SQG - SQL Query Generator - Type-safe code generation from SQL (https://sqg.dev)";
|
|
2242
2247
|
consola.level = LogLevels.info;
|
|
2243
2248
|
const program = new Command().name("sqg").description(`${description}
|
|
@@ -49,6 +49,18 @@ public class {{className}} {
|
|
|
49
49
|
throw new RuntimeException(e);
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
+
|
|
53
|
+
private static LocalDateTime toLocalDateTime(java.sql.Timestamp ts) {
|
|
54
|
+
return ts != null ? ts.toLocalDateTime() : null;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static LocalDate toLocalDate(java.sql.Date d) {
|
|
58
|
+
return d != null ? d.toLocalDate() : null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private static LocalTime toLocalTime(java.sql.Time t) {
|
|
62
|
+
return t != null ? t.toLocalTime() : null;
|
|
63
|
+
}
|
|
52
64
|
|
|
53
65
|
private static <K> List<K> arrayToList(
|
|
54
66
|
Array array,
|