From 8213c85c24d1615a589083d4a243074294402dcc Mon Sep 17 00:00:00 2001 From: Cedric Vangout Date: Mon, 8 Jan 2024 20:24:04 +0100 Subject: [PATCH 1/2] feat: add datatypes aliases --- crates/parser/src/parse/libpg_query_node.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/crates/parser/src/parse/libpg_query_node.rs b/crates/parser/src/parse/libpg_query_node.rs index bad223fc..76770fd1 100644 --- a/crates/parser/src/parse/libpg_query_node.rs +++ b/crates/parser/src/parse/libpg_query_node.rs @@ -412,7 +412,23 @@ impl<'p> LibpgQueryNodeParser<'p> { } /// list of aliases from https://www.postgresql.org/docs/current/datatype.html -const ALIASES: [&[&str]; 2] = [&["integer", "int", "int4"], &["real", "float4"]]; +const ALIASES: [&[&str]; 15] = [ + &["bigint", "int8"], + &["bigserial", "serial8"], + &["bit varying", "varbit"], + &["boolean", "bool"], + &["character", "char"], + &["character varying", "varchar"], + &["double precision", "float8"], + &["integer", "int", "int4"], + &["numeric", "decimal"], + &["real", "float4"], + &["smallint", "int2"], + &["smallserial", "serial2"], + &["serial", "serial4"], + &["time with time zone", "timetz"], + &["timestamp with time zone", "timestamptz"], +]; fn cmp_tokens(p: &crate::codegen::TokenProperty, token: &crate::lexer::Token) -> bool { // TokenProperty has always either value or kind set From 5352e3efcee0f11588045ea2b23f2fc9fbd6bada Mon Sep 17 00:00:00 2001 From: Cedric Vangout Date: Mon, 8 Jan 2024 23:38:50 +0100 Subject: [PATCH 2/2] skip multi-word aliases --- crates/parser/src/parse/libpg_query_node.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/crates/parser/src/parse/libpg_query_node.rs b/crates/parser/src/parse/libpg_query_node.rs index 76770fd1..c24d255f 100644 --- a/crates/parser/src/parse/libpg_query_node.rs +++ b/crates/parser/src/parse/libpg_query_node.rs @@ -412,22 +412,18 @@ impl<'p> LibpgQueryNodeParser<'p> { } /// list of aliases from https://www.postgresql.org/docs/current/datatype.html -const ALIASES: [&[&str]; 15] = [ +/// NOTE: support for multi-word alias (e.g. time with time zone) requires parser change +const ALIASES: [&[&str]; 10] = [ &["bigint", "int8"], &["bigserial", "serial8"], - &["bit varying", "varbit"], &["boolean", "bool"], &["character", "char"], - &["character varying", "varchar"], - &["double precision", "float8"], &["integer", "int", "int4"], &["numeric", "decimal"], &["real", "float4"], &["smallint", "int2"], &["smallserial", "serial2"], &["serial", "serial4"], - &["time with time zone", "timetz"], - &["timestamp with time zone", "timestamptz"], ]; fn cmp_tokens(p: &crate::codegen::TokenProperty, token: &crate::lexer::Token) -> bool {