From 633e85fdf329561d17f1741648675839268d7d68 Mon Sep 17 00:00:00 2001 From: Mark Nguyen Date: Sat, 6 Jun 2026 14:12:42 -0700 Subject: [PATCH] fix(postgres): Allow casting to UUID array --- pegjs/postgresql.pegjs | 6 +++--- test/postgres.spec.js | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/pegjs/postgresql.pegjs b/pegjs/postgresql.pegjs index 7322b7020..dfa4915d4 100644 --- a/pegjs/postgresql.pegjs +++ b/pegjs/postgresql.pegjs @@ -5742,15 +5742,15 @@ data_type array_type - = t:(numeric_type / character_string_type / text_type) __ LBRAKE __ RBRAKE __ LBRAKE __ RBRAKE { + = t:(numeric_type / character_string_type / text_type / uuid_type) __ LBRAKE __ RBRAKE __ LBRAKE __ RBRAKE { /* => data_type */ return { ...t, array: { dimension: 2 } } } - / t:(numeric_type / character_string_type / text_type) __ LBRAKE __ l:literal_numeric? __ RBRAKE { + / t:(numeric_type / character_string_type / text_type / uuid_type) __ LBRAKE __ l:literal_numeric? __ RBRAKE { /* => data_type */ return { ...t, array: { dimension: 1, length: [l] } } } - / t:(numeric_type / character_string_type / text_type) __ KW_ARRAY { + / t:(numeric_type / character_string_type / text_type / uuid_type) __ KW_ARRAY { /* => data_type */ return { ...t, array: { keyword: 'array' } } } diff --git a/test/postgres.spec.js b/test/postgres.spec.js index b85da66ae..e47391f61 100644 --- a/test/postgres.spec.js +++ b/test/postgres.spec.js @@ -2072,6 +2072,13 @@ describe('Postgres', () => { 'CREATE TABLE "test_table" (id INT NOT NULL, vector TSVECTOR)' ] }, + { + title: 'cast to uuid array type', + sql: [ + `SELECT string_to_array('a,b', ',')::uuid[]`, + `SELECT string_to_array('a,b', ',')::UUID[]` + ] + }, ] function neatlyNestTestedSQL(sqlList){ sqlList.forEach(sqlInfo => {