Skip to content

Commit 52629bd

Browse files
committed
fix casts
1 parent f9a04ce commit 52629bd

File tree

5 files changed

+38
-9
lines changed

5 files changed

+38
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# DuckDB Connector Changelog
22
This changelog documents changes between release tags.
33

4+
## [0.1.5] - 2025-01-15
5+
* Fix order by LOWER cast
6+
47
## [0.1.4] - 2025-01-08
58
* Update to fix a bug to add support for UBigInt, HugeInt, UHugeInt
69
* Add support for Timestamps with Timezone

connector-definition/connector-metadata.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
packagingDefinition:
22
type: PrebuiltDockerImage
3-
dockerImage: ghcr.io/hasura/ndc-duckdb:v0.1.4
3+
dockerImage: ghcr.io/hasura/ndc-duckdb:v0.1.5
44
supportedEnvironmentVariables:
55
- name: DUCKDB_URL
66
description: The url for the DuckDB database
77
commands:
88
update:
99
type: Dockerized
10-
dockerImage: ghcr.io/hasura/ndc-duckdb:v0.1.4
10+
dockerImage: ghcr.io/hasura/ndc-duckdb:v0.1.5
1111
commandArgs:
1212
- update
1313
dockerComposeWatch:

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "duckdb-sdk",
3-
"version": "0.1.4",
3+
"version": "0.1.5",
44
"description": "",
55
"main": "index.js",
66
"scripts": {

src/handlers/query.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,23 @@ function getColumnExpression(field_def: ObjectField, collection_alias: string, c
6262
return processType(field_def.type);
6363
}
6464

65-
function isTimestampType(field_def: any): boolean {
65+
function isStringType(field_def: ObjectField | undefined): boolean {
66+
if (!field_def) return false;
67+
68+
function checkType(type: any): boolean {
69+
if (type.type === "nullable") {
70+
return checkType(type.underlying_type);
71+
}
72+
if (type.type === "array") {
73+
return false;
74+
}
75+
return type.type === "named" && type.name === "String";
76+
}
77+
78+
return checkType(field_def.type);
79+
}
80+
81+
function isTimestampType(field_def: ObjectField | undefined): boolean {
6682
if (!field_def) return false;
6783

6884
function checkType(type: any): boolean {
@@ -74,7 +90,7 @@ function isTimestampType(field_def: any): boolean {
7490

7591
return checkType(field_def.type);
7692
}
77-
function getIntegerType(field_def: any): string | null {
93+
function getIntegerType(field_def: ObjectField | undefined): string | null {
7894
if (!field_def) return null;
7995

8096
function checkType(type: any): string | null {
@@ -411,11 +427,16 @@ function build_query(
411427
switch (elem.target.type) {
412428
case "column":
413429
if (elem.target.path.length === 0){
430+
const field_def = config.config.object_types[query_request.collection].fields[elem.target.name];
431+
const is_string = isStringType(field_def);
432+
const field_name = is_string ? `LOWER(${escape_double(collection_alias)}.${escape_double(elem.target.name)})` : `${escape_double(collection_alias)}.${escape_double(elem.target.name)}`
414433
order_elems.push(
415-
`LOWER(${escape_double(collection_alias)}.${escape_double(elem.target.name)}) ${elem.order_direction}`
434+
`${field_name} ${elem.order_direction}`
416435
);
417436
} else {
418437
let currentAlias = collection_alias;
438+
let current_collection = query_request.collection;
439+
let field_def = config.config.object_types[current_collection].fields[elem.target.name];
419440
for (let path_elem of elem.target.path) {
420441
const relationship = collection_relationships[path_elem.relationship];
421442
const nextAlias = `${currentAlias}_${relationship.target_collection}`;
@@ -425,9 +446,13 @@ function build_query(
425446
filter_joins.push(join_str);
426447
}
427448
currentAlias = nextAlias;
449+
current_collection = relationship.target_collection;
450+
field_def = config.config.object_types[current_collection].fields[elem.target.name];
428451
}
452+
const is_string = isStringType(field_def);
453+
const field_name = is_string ? `LOWER(${escape_double(currentAlias)}.${escape_double(elem.target.name)})` : `${escape_double(currentAlias)}.${escape_double(elem.target.name)}`;
429454
order_elems.push(
430-
`${escape_double(currentAlias)}.${escape_double(elem.target.name)} ${elem.order_direction}`
455+
`${field_name} ${elem.order_direction}`
431456
);
432457
}
433458
break;
@@ -569,6 +594,7 @@ export async function do_query(
569594
state: State,
570595
query: QueryRequest
571596
): Promise<QueryResponse> {
597+
// console.log(JSON.stringify(query, null, 4));
572598
let query_plans = await plan_queries(configuration, query);
573599
return await perform_query(state, query_plans);
574600
}

0 commit comments

Comments
 (0)