diff --git a/src/parser/mod.rs b/src/parser/mod.rs index 7b79d1c8..9d1f1169 100644 --- a/src/parser/mod.rs +++ b/src/parser/mod.rs @@ -3317,7 +3317,7 @@ impl<'a> Parser<'a> { return_type: None, params, }) - } else if dialect_of!(self is PostgreSqlDialect) { + } else if dialect_of!(self is PostgreSqlDialect | GenericDialect) { let name = self.parse_object_name(false)?; self.expect_token(&Token::LParen)?; let args = if self.consume_token(&Token::RParen) { diff --git a/tests/sqlparser_hive.rs b/tests/sqlparser_hive.rs index 66eef09e..934d25a4 100644 --- a/tests/sqlparser_hive.rs +++ b/tests/sqlparser_hive.rs @@ -19,7 +19,7 @@ use sqlparser::ast::{ CreateFunctionBody, CreateFunctionUsing, Expr, Function, FunctionDefinition, Ident, ObjectName, SelectItem, Statement, TableFactor, UnaryOperator, Value, }; -use sqlparser::dialect::{GenericDialect, HiveDialect}; +use sqlparser::dialect::{GenericDialect, HiveDialect, MsSqlDialect}; use sqlparser::parser::{ParserError, ParserOptions}; use sqlparser::test_utils::*; @@ -285,8 +285,14 @@ fn parse_create_function() { _ => unreachable!(), } + // Test error in dialect that doesn't support parsing CREATE FUNCTION + let unsupported_dialects = TestedDialects { + dialects: vec![Box::new(MsSqlDialect {})], + options: None, + }; + assert_eq!( - generic(None).parse_sql_statements(sql).unwrap_err(), + unsupported_dialects.parse_sql_statements(sql).unwrap_err(), ParserError::ParserError( "Expected an object type after CREATE, found: FUNCTION".to_string() ) diff --git a/tests/sqlparser_postgres.rs b/tests/sqlparser_postgres.rs index c06d0971..9fe41491 100644 --- a/tests/sqlparser_postgres.rs +++ b/tests/sqlparser_postgres.rs @@ -3257,7 +3257,7 @@ fn parse_similar_to() { fn parse_create_function() { let sql = "CREATE FUNCTION add(INTEGER, INTEGER) RETURNS INTEGER LANGUAGE SQL IMMUTABLE AS 'select $1 + $2;'"; assert_eq!( - pg().verified_stmt(sql), + pg_and_generic().verified_stmt(sql), Statement::CreateFunction { or_replace: false, temporary: false,