Skip to content

Add support for $$ in CREATE FUNCTION for generic dialect #1183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
milenkovicm opened this issue Mar 16, 2024 · 0 comments · Fixed by #1185
Closed

Add support for $$ in CREATE FUNCTION for generic dialect #1183

milenkovicm opened this issue Mar 16, 2024 · 0 comments · Fixed by #1185

Comments

@milenkovicm
Copy link
Contributor

At the moment generic dialect does not support $$ in CREATE FUNCTION .. AS, would it make sense supporting it?

It should be straight forward adding support for it

diff --git a/src/parser/mod.rs b/src/parser/mod.rs
index a719056..5bdaf5c 100644
--- a/src/parser/mod.rs
+++ b/src/parser/mod.rs
@@ -5954,7 +5954,7 @@ impl<'a> Parser<'a> {
     pub fn parse_function_definition(&mut self) -> Result<FunctionDefinition, ParserError> {
         let peek_token = self.peek_token();
         match peek_token.token {
-            Token::DollarQuotedString(value) if dialect_of!(self is PostgreSqlDialect) => {
+            Token::DollarQuotedString(value) if dialect_of!(self is PostgreSqlDialect | GenericDialect) => {
                 self.next_token();
                 Ok(FunctionDefinition::DoubleDollarDef(value.value))
             }
diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs
index 9de4b98..033ae6f 100644
--- a/tests/sqlparser_postgres.rs
+++ b/tests/sqlparser_postgres.rs
@@ -3335,7 +3335,7 @@ fn parse_create_function() {
 
     let sql = r#"CREATE OR REPLACE FUNCTION increment(i INTEGER) RETURNS INTEGER LANGUAGE plpgsql AS $$ BEGIN RETURN i + 1; END; $$"#;
     assert_eq!(
-        pg().verified_stmt(sql),
+        pg_and_generic().verified_stmt(sql),
         Statement::CreateFunction {
             or_replace: true,
             temporary: false,
milenkovicm added a commit to milenkovicm/sqlparser-rs that referenced this issue Mar 16, 2024
milenkovicm added a commit to milenkovicm/sqlparser-rs that referenced this issue Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant