From: Michael Orlitzky Date: Sun, 12 Jan 2014 05:01:54 +0000 (-0500) Subject: USe lowerCaseSuffixNamingStyle as our base in TSN.Codegen. X-Git-Tag: 0.0.1~91 X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=99f376a8258115dbc2d49c237d79a467488ff0c1;p=dead%2Fhtsn-import.git USe lowerCaseSuffixNamingStyle as our base in TSN.Codegen. --- diff --git a/src/TSN/Codegen.hs b/src/TSN/Codegen.hs index 38aede4..467f86b 100644 --- a/src/TSN/Codegen.hs +++ b/src/TSN/Codegen.hs @@ -9,10 +9,14 @@ import Data.List.Utils ( join, split ) import Database.Groundhog.TH ( CodegenConfig ( namingStyle ), NamingStyle ( mkDbConstrName, mkDbFieldName, mkExprFieldName ), - defaultCodegenConfig ) + defaultCodegenConfig, + lowerCaseSuffixNamingStyle ) -default_ns :: NamingStyle -default_ns = namingStyle defaultCodegenConfig +-- | The lowercase naming style for database entities, provided by +-- Groundhog. Makes a better starting point than the default. +-- +lowercase_ns :: NamingStyle +lowercase_ns = lowerCaseSuffixNamingStyle -- | A database field name creator. It takes the field name (from a -- record type) and drops the first component determined by @@ -22,10 +26,6 @@ tsn_db_field_namer :: String -> String -> Int -> String -> Int -> String tsn_db_field_namer _ _ _ fieldname _ = (join "_") . tail . (split "_") $ fieldname -tsn_db_constr_namer :: String -> String -> Int -> String -tsn_db_constr_namer _ constrname _ = - map toLower constrname - tsn_expr_field_namer :: String -> String -> Int -> String -> Int -> String tsn_expr_field_namer _ _ _ fieldname _ = (join "_") . (map capitalize) . (split "_") $ fieldname @@ -34,9 +34,8 @@ tsn_expr_field_namer _ _ _ fieldname _ = capitalize (c:cs) = (toUpper c : cs) tsn_naming_style :: NamingStyle -tsn_naming_style = default_ns { mkDbConstrName = tsn_db_constr_namer, - mkDbFieldName = tsn_db_field_namer, - mkExprFieldName = tsn_expr_field_namer } +tsn_naming_style = lowercase_ns { mkDbFieldName = tsn_db_field_namer, + mkExprFieldName = tsn_expr_field_namer } tsn_codegen_config :: CodegenConfig tsn_codegen_config =