From 27feb8552183af07af9ea2c3d4ba7eaf8bc1127d Mon Sep 17 00:00:00 2001 From: Michael Toy <66150587+mtoy-googly-moogly@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:09:38 -0800 Subject: [PATCH] pg arrays almost --- packages/malloy/src/dialect/postgres/postgres.ts | 3 +-- test/src/databases/all/compound-atomic.spec.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/malloy/src/dialect/postgres/postgres.ts b/packages/malloy/src/dialect/postgres/postgres.ts index 2ed407e2e..7b4fe75fa 100644 --- a/packages/malloy/src/dialect/postgres/postgres.ts +++ b/packages/malloy/src/dialect/postgres/postgres.ts @@ -457,8 +457,7 @@ export class PostgresDialect extends PostgresBase { } sqlLiteralArray(lit: ArrayLiteralNode): string { - // mtoy todo real quoting of values ... strings with quotes will break thi const array = lit.kids.values.map(val => val.sql); - return `'${JSON.stringify(array)}'::jsonb`; + return `ARRAY[${array.join(',')}]`; } } diff --git a/test/src/databases/all/compound-atomic.spec.ts b/test/src/databases/all/compound-atomic.spec.ts index 2418b2cda..2f966392c 100644 --- a/test/src/databases/all/compound-atomic.spec.ts +++ b/test/src/databases/all/compound-atomic.spec.ts @@ -125,7 +125,7 @@ describe.each(runtimes.runtimeList)( const nameOfArrayLenFunction = { 'duckdb': 'LEN', 'standardsql': 'ARRAY_LENGTH', - 'postgres': 'JSONB_ARRAY_LENGTH', + 'postgres': 'CARDINALITY', 'presto': 'CARDINALITY', 'trino': 'CARDINALITY', 'mysql': 'JSON_LENGTH',