From 72a684664e55d58d332fe4249f91cd371c354a82 Mon Sep 17 00:00:00 2001 From: Kazuki Okamoto Date: Sat, 11 Jun 2016 22:41:01 +0900 Subject: [PATCH] quote column name --- .gitignore | 2 ++ relational-query/src/Database/Relational/Query/TH.hs | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 05f7f413..deea681d 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ cabal.sandbox.config *.aux *.hp /.stack-work/ +.idea/ +*.iml diff --git a/relational-query/src/Database/Relational/Query/TH.hs b/relational-query/src/Database/Relational/Query/TH.hs index 5d00dbef..21bbec85 100644 --- a/relational-query/src/Database/Relational/Query/TH.hs +++ b/relational-query/src/Database/Relational/Query/TH.hs @@ -270,9 +270,11 @@ tableSQL normalize snm iq schema table = case snm of normalizeT | normalize = map toLower table | otherwise = table - qt s = case iq of - NoQuotation -> s - Quotation qc -> qc : s ++ qc : [] -- TODO: Escaping. + qt = quote iq + +quote :: IdentifierQuotation -> String -> String +quote NoQuotation s = s +quote (Quotation qc) s = qc : s ++ qc : [] -- TODO: Escaping. derivationVarNameDefault :: String -> VarName derivationVarNameDefault = (`varNameWithPrefix` "derivationFrom") @@ -336,7 +338,7 @@ defineTableTypesWithConfig config schema table columns = do (table `varNameWithPrefix` "insertQuery") (recordType recConfig schema table) (tableSQL (normalizedTableName config) (schemaNameMode config) (identifierQuotation config) schema table) - (map (fst . fst) columns) + (map ((quote (identifierQuotation config)) . fst . fst) columns) colsDs <- defineColumnsDefault (recordTypeName recConfig schema table) columns return $ tableDs ++ colsDs