Closed MangelMaxime closed 1 year ago
Do I need to set a configuration option somewhere for SQLKata to generate be aware that I am using PostgreSQL?
Oh...
I forgot to change SqlKata.Compilers.SqlServerCompiler()
to SqlKata.Compilers.PostgresCompiler()
.
Got bitten once again by the openContext
function 😅
Glad you found the cause! Btw, you can output the SQL with this helper function:
let toSql (query: SqlKata.Query) =
let compiler = SqlKata.Compilers.PostgresCompiler()
compiler.Compile(query).Sql
Example:
let query =
delete {
for _ in table<dbo.EncounterForms> do
deleteAll
}
query.ToKataQuery() |> toSql |> printfn "%s"
Thank you for the utility function, I never had to check the generate code yet but could be handy one day.
Btw, SqlHydra has some nice features for Npgsql:
open SqlHydra.Query.NpgsqlExtensions
:
I saw this additional features indeed, and will definitely look into them.
We are already interesting in the Enum stuff to avoid having to create manual mapping between our DUs and "types table" to enforce the integrity.
Do you know if SqlHydra support arrays of enums too?
I haven’t tried that specifically, but i don’t see any reason why it wouldn’t work since the array types are not hardcoded.
Hello @JordanMarr,
in our project we are moving away from SQLServer to go to PostgreSQL.
I installed
SqlHydra.Npgsql
tool and generated the new database files.I also installed Npgsql and removed the System.Data.SqlClient library.
My project is now compiling how when running the tests I get the following error:
I feel like the
[
syntax error is because the generated SQL is for SQLServer instead of PostgreSQL.The query which trigger the error is:
Is there something I am missing? Is it possible to see the generated SQL by SQL Hydra to try understand the problem?