khibino / haskell-relational-record

This repository includes a joined query generator based on typefull relational algebra, and mapping tools between SQL values list and Haskell record type.
234 stars 36 forks source link

schemas name case is not preserved #39

Closed ryantm closed 8 years ago

ryantm commented 8 years ago

I have a lowercase-named database in MySQL and when I use defineTable

defineTable :: String -> Q [Dec]
defineTable tableName =
  defineTableFromDB
    connect
    driverMySQL
    "dbname"
    tableName
    [''Show]

The generated SQL statements include references to the table name like DBNAME.tablename, which does not work because MySQL defaults to case sensitive on Unix systems:

http://dev.mysql.com/doc/refman/5.7/en/identifier-case-sensitivity.html

I believe this links to the line that is the problem:

https://github.com/khibino/haskell-relational-record/blob/e6bb2bcada551bee956cf526233f3768e8e62920/relational-query/src/Database/Relational/Query/TH.hs#L268

ryantm commented 8 years ago

okay, I figured out I needed to use defineTableFromDB' which lets me pass in the mysql config that turns off normalizing the table names. https://github.com/khibino/haskell-relational-record/blob/e6bb2bcada551bee956cf526233f3768e8e62920/relational-schemas/src/Database/Relational/Schema/MySQLInfo/Config.hs

I recommend adding that to the mysql example. https://github.com/khibino/haskell-relational-record/blob/master/examples/HDBC/MySQL/src/Example/DataSource.hs