Skip to content
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

Javascript procedure support #7

Open
sjauld opened this issue Apr 18, 2022 · 1 comment
Open

Javascript procedure support #7

sjauld opened this issue Apr 18, 2022 · 1 comment

Comments

@sjauld
Copy link
Member

sjauld commented Apr 18, 2022

Hello. We are using the DbUp.Snowflake extension and are encountering errors when our SnowFlake scripts contain embedded JavaScript. The issue seems to be related to cases where we have multiple lines where the JavaScript command lines end with a ';' char.

Here is an example that we have been using. It is an example script from the SnowFlake website: create or replace procedure sp_pi() returns float not null language javascript as $$ return 3.1415926; $$ ;

The SnowflakeConnectionManager.SplitScriptIntoCommands takes this script and creates an array as [0] "create or replace procedure sp_pi()\r\n returns float not null\r\n language javascript\r\n as\r\n $$\r\n return 3.1415926" [1] "$$"

As you can see, we are now missing the closing $$ chars due to the split on the ';' char at the end of the JavaScript line in the 1st command and the 2nd command is just the closing $$ chars. This is raising an error:

System.Data.Odbc.OdbcException (0x80131937): ERROR [42000] SQL compilation error: parse error line 6 at position 20 near ''. syntax error line 5 at position 5 unexpected '$'. at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader, Object[] methodArguments, SQL_API odbcApiMethod) at System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior behavior, String method, Boolean needReader) at System.Data.Odbc.OdbcCommand.ExecuteNonQuery() at DbUp.Support.ScriptExecutor.ExecuteNonQuery(IDbCommand command) in C:\Dev\DbUpSnowFlakeTest\src\dbup-core\Support\ScriptExecutor.cs:line 173 at DbUp.Support.ScriptExecutor.<>c__DisplayClass18_2.b__1() in C:\Dev\DbUpSnowFlakeTest\src\dbup-core\Support\ScriptExecutor.cs:line 146 at DbUp.Snowflake.SnowflakeScriptExecutor.ExecuteCommandsWithinExceptionHandler(Int32 index, SqlScript script, Action executeCallback) in C:\Dev\DbUpSnowFlakeTest\src\dbup-snowflake\SnowflakeScriptExecutor.cs:line 27

However, when we flatten out the script to a single line, the extension works as expected without any errors. So it seems to do with the regex in SnowflakeConnectionManager.SplitScriptIntoCommands.

Are we missing something with our usage of the Snowflake extension?

Thx. -Bill

@ivonneroche
Copy link

I'm having the same issue. It will be nice if we don't need to flatten the code, difficult to read.

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

No branches or pull requests

2 participants