@ts-safeql/generate
Advanced tools
Comparing version 1.0.0 to 1.0.1
@@ -26,2 +26,4 @@ import { DuplicateColumnsError, IdentiferCase, LibPgQueryAST, PostgresError } from "@ts-safeql/shared"; | ||
fieldTransform: IdentiferCase | undefined; | ||
nullAsUndefined?: boolean; | ||
nullAsOptional?: boolean; | ||
overrides?: Partial<{ | ||
@@ -28,0 +30,0 @@ types: Record<string, OverrideValue>; |
@@ -69,2 +69,4 @@ "use strict"; | ||
fieldTransform: params.fieldTransform, | ||
nullAsUndefined: params.nullAsUndefined, | ||
nullAsOptional: params.nullAsOptional, | ||
}), | ||
@@ -103,2 +105,4 @@ stmt: result, | ||
fieldTransform: params.fieldTransform, | ||
nullAsUndefined: params.nullAsUndefined, | ||
nullAsOptional: params.nullAsOptional, | ||
}); | ||
@@ -110,4 +114,8 @@ return propertySignature; | ||
function buildInterfacePropertyValue(params) { | ||
const nullType = params.nullAsUndefined ? "undefined" : "null"; | ||
const isNullable = params.isNullable && ["any", "null"].includes(params.value) === false; | ||
return [params.key, isNullable ? `${params.value} | null` : params.value]; | ||
if (!isNullable) { | ||
return [params.key, params.value]; | ||
} | ||
return [params.nullAsOptional ? `${params.key}?` : params.key, `${params.value} | ${nullType}`]; | ||
} | ||
@@ -190,2 +198,4 @@ function checkIsNullableDueToRelation(params) { | ||
isNullable: !isNonNullable, | ||
nullAsUndefined: params.nullAsUndefined, | ||
nullAsOptional: params.nullAsOptional, | ||
}); | ||
@@ -192,0 +202,0 @@ } |
@@ -258,2 +258,10 @@ "use strict"; | ||
}); | ||
(0, mocha_1.test)("select from subselect with an alias", async () => { | ||
await testQuery({ | ||
query: ` | ||
SELECT subselect.id FROM (SELECT * FROM caregiver) AS subselect | ||
`, | ||
expected: [["id", "number"]], | ||
}); | ||
}); | ||
//# sourceMappingURL=generate.test.js.map |
@@ -21,3 +21,3 @@ "use strict"; | ||
function recursiveTraverseJoins(joins, joinExpr) { | ||
var _a, _b, _c; | ||
var _a, _b, _c, _d, _e; | ||
if (((_a = joinExpr.rarg) === null || _a === void 0 ? void 0 : _a.RangeVar) !== undefined) { | ||
@@ -28,2 +28,8 @@ const join = { type: joinExpr.jointype, name: joinExpr.rarg.RangeVar.relname }; | ||
} | ||
if (((_e = (_d = joinExpr.larg) === null || _d === void 0 ? void 0 : _d.RangeSubselect) === null || _e === void 0 ? void 0 : _e.alias) !== undefined) { | ||
return { | ||
relName: joinExpr.larg.RangeSubselect.alias.aliasname, | ||
joins: [join, ...joins], | ||
}; | ||
} | ||
return { relName: joinExpr.larg.RangeVar.relname, joins: [join, ...joins] }; | ||
@@ -30,0 +36,0 @@ } |
{ | ||
"name": "@ts-safeql/generate", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78723
1107