You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi Everyone, i want a ask about Sql builder.
I want to create database schema with postgreSql provider using sql builder function , but when this function executed with below code, the result always generated "0" as schema name
When i try with this code sql.Append("DECLARE myvar TEXT = @0 ; ","demo"); the result it should be DECLARE myvar TEXT = 'demo' instead it became like this DECLARE myvar TEXT = '0 .
and i try with this code sql.Append($"DECLARE myvar TEXT = '{schemaName}' ; "); and its works.
but I want to avoid sql injection, therefore I use sql builder function.
**Fullcode below **
Sqlsql=newSql();sql.Append("DO $$");sql.Append($"DECLARE myvar TEXT = '{name}' ; ");sql.Append("BEGIN EXECUTE 'CREATE SCHEMA ' || quote_ident(myvar); END $$;");awaitdatabase.ExecuteAsync(sql);
Thank you.
The text was updated successfully, but these errors were encountered:
I don't think this is an issue with PetaPoco -- the SQL fed to the command seems to be just what you asked for. Are you sure that Postgres allows the use of parameters in declaring a variable?
Hi Everyone, i want a ask about Sql builder.
I want to create database schema with postgreSql provider using sql builder function , but when this function executed with below code, the result always generated "0" as schema name
When i try with this code
sql.Append("DECLARE myvar TEXT = @0 ; ","demo");
the result it should beDECLARE myvar TEXT = 'demo'
instead it became like thisDECLARE myvar TEXT = '0
.and i try with this code
sql.Append($"DECLARE myvar TEXT = '{schemaName}' ; ");
and its works.but I want to avoid sql injection, therefore I use sql builder function.
**Fullcode below **
Thank you.
The text was updated successfully, but these errors were encountered: