Skip to content

Commit 6a1f922

Browse files
committed
Fix query builder not being able to render EdgeQL for luxon object literals
1 parent 2702d6d commit 6a1f922

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/core/edgedb/generator/query-builder.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export async function generateQueryBuilder({
2222
});
2323
addJsExtensionDeepPathsOfEdgedbLibrary(qbDir);
2424
changeCustomScalars(qbDir);
25+
updateEdgeQLRenderingForOurCustomScalars(qbDir);
2526
changeImplicitIDType(qbDir);
2627
allowOrderingByEnums(qbDir);
2728
mergeDefaultTypesWithModuleNames(qbDir);
@@ -66,6 +67,23 @@ function changeImplicitIDType(qbDir: Directory) {
6667
);
6768
}
6869

70+
function updateEdgeQLRenderingForOurCustomScalars(qbDir: Directory) {
71+
const file = qbDir.addSourceFileAtPath('toEdgeQL.ts');
72+
file.insertImportDeclaration(1, {
73+
namedImports: ['DateTime'],
74+
moduleSpecifier: 'luxon',
75+
leadingTrivia: '\n',
76+
});
77+
const condition = ' } else if (val instanceof Date) {\n';
78+
const updated = file.getText().replace(
79+
condition,
80+
` } else if (val instanceof DateTime) {
81+
stringRep = \`'\${val.toISO()}'\`;
82+
` + condition,
83+
);
84+
file.replaceWithText(updated);
85+
}
86+
6987
function allowOrderingByEnums(qbDir: Directory) {
7088
const file = qbDir.getSourceFileOrThrow('select.ts');
7189
file

0 commit comments

Comments
 (0)