From 39ba44ef244411c449931900ad01326308c15a93 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Wed, 21 Mar 2018 17:22:42 +0100 Subject: [PATCH] Convert WITH(NO VARIANT) to IMMUTABLE for PostgreSQL target Closes #21 --- sqlparser/statements.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sqlparser/statements.cpp b/sqlparser/statements.cpp index 48638c0..06ba57c 100644 --- a/sqlparser/statements.cpp +++ b/sqlparser/statements.cpp @@ -9478,7 +9478,33 @@ bool SqlParser::ParseFunctionOptions() exists = true; continue; } - + // WITH ( options ) in PostgreSQL + if(next->Compare("WITH", L"WITH", 4) == true) + { + if(_target == SQL_POSTGRESQL) + { + Token *open = GetNextCharToken('(', L'('); + if ( open ) + { + Token *negate = GetNextWordToken("NOT", L"NOT", 3); + if ( negate ) { + Token *variant = GetNextWordToken("VARIANT", L"VARIANT", 7); + if ( variant ) + { + Token::Remove(next, negate); + Token::Change(variant, "IMMUTABLE", L"IMMUTABLE", 9); + } + } + Token *close = GetNextCharToken(')', L')'); + Token *semicolon = GetNextCharToken(';', L';'); + Token::Remove(close, semicolon); + } + } + + exists = true; + continue; + } + // Not a function option PushBack(next); break;