Dzoukr / Dapper.FSharp

Lightweight F# extension for StackOverflow Dapper with support for MSSQL, MySQL, PostgreSQL, and SQLite
MIT License
365 stars 35 forks source link

Allow specifying database schema in builders #16

Closed ssiltanen closed 3 years ago

ssiltanen commented 3 years ago

Currently all queries created by Dapper.FSharp use the default database schema eg dbo in SQL Server. Adding schema to builders it would be possible run queries to other schemas too.

eg.

select {
    schema "staging"
    table "User"
}

// SELECT ... FROM [staging].[User]

Omitting schema could work as it does now, to avoid issues with backwards compatibility.

Currently there is no way to use Dapper.FSharp to go around this other than getting the SQL out and injecting the schema there by yourself.

Dzoukr commented 3 years ago

As usual, great idea! I'll try to fix that soon.

travis-leith commented 3 years ago

I don't use SQL server very often, but is this not another way?

select {
    table "staging.User"
}
ssiltanen commented 3 years ago

It does not work because table and columns are wrapped in brackets [], which is done to allow keywords in column and table names.

Dzoukr commented 3 years ago

Done in v1.15.0. On your Nuget feed in few minutes.