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

exception raised when column names are reserved names #8

Closed simonmcconnell closed 4 years ago

simonmcconnell commented 4 years ago
type MyDatabaseProjection = {
    Id : int
    Name : string
    Desc : string
}

let getById connectionString id = task {
    use c = new SqlConnection(connectionString)
    return! select { table "MyTable" where (eq "Id" id) } |> c.SelectAsync<MyDatabaseProjection>
}

This will give SELECT Id, Desc FROM MyTable WHERE Id=1 and raise an exception, when it really just needs to be something like SELECT [Id], [Desc] FROM [MyTable] WHERE Id=1. Do you have any objections to putting square brackets around the terms?

Dzoukr commented 4 years ago

Sure, I'll look at it (or you can send a PR). Which database? MSSQL, MySQL or Postgres?

simonmcconnell commented 4 years ago

MSSQL. I can try a PR in the coming days.

On Mon, 6 Jul 2020, 17:25 Roman Provazník, notifications@github.com wrote:

Sure, I'll look at it (or you can send a PR). Which database? MSSQL, MySQL or Postgres?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dzoukr/Dapper.FSharp/issues/8#issuecomment-654063508, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFMFOAESLU5DFLR4U7P2UCTR2F36ZANCNFSM4OQS55SA .

Dzoukr commented 4 years ago

Fixed in v 1.10.0 - checked for all three databases. Thanks for pointing out, @simonmcconnell!