Use raw SQL string definitions to keep simple package dependencies.

This commit is contained in:
Kei Hibino 2014-05-13 15:38:09 +09:00
parent 7b1b1191c7
commit 5a77e6d5c6
2 changed files with 8 additions and 6 deletions

View File

@ -36,8 +36,8 @@ import Language.Haskell.TH.Name.CamelCase (varCamelcaseName)
import Database.Record.TH (makeRecordPersistableWithSqlTypeDefault)
import qualified Database.Record.TH as Record
import Database.Relational.Query (Relation, Config, sqlFromRelationWith)
import Database.Relational.Query.SQL (QuerySuffix, showsQuerySuffix)
import Database.Relational.Query (Relation, Config, relationalQuerySQL)
import Database.Relational.Query.SQL (QuerySuffix)
import qualified Database.Relational.Query.TH as Relational
import Database.HDBC.Session (withConnectionIO)
@ -130,7 +130,7 @@ inlineVerifiedQuery :: IConnection conn
-> Q [Dec] -- ^ Result declarations
inlineVerifiedQuery connect relVar rel config sufs qns = do
(p, r) <- Relational.reifyRelation relVar
let sql = sqlFromRelationWith rel config . showsQuerySuffix sufs $ ""
let sql = relationalQuerySQL config rel sufs
_ <- runIO $ withConnectionIO connect
(\conn -> do
putLog $ "Verify with prepare: " ++ sql

View File

@ -79,13 +79,13 @@ import Database.Record.Instances ()
import Database.Relational.Query
(Table, Pi, Relation, Config, ProductConstructor (..),
sqlFromRelationWith, Query, relationalQuery, KeyUpdate, Insert,
relationalQuerySQL, Query, relationalQuery, KeyUpdate, Insert,
HasConstraintKey(constraintKey), projectionKey, Primary, NotNull)
import Database.Relational.Query.Scalar (defineScalarDegree)
import Database.Relational.Query.Constraint (Key, unsafeDefineConstraintKey)
import qualified Database.Relational.Query.Table as Table
import Database.Relational.Query.SQL (QuerySuffix, showsQuerySuffix)
import Database.Relational.Query.SQL (QuerySuffix)
import Database.Relational.Query.Type (unsafeTypedQuery)
import qualified Database.Relational.Query.Pi.Unsafe as UnsafePi
import Database.Relational.Query.Derives
@ -424,4 +424,6 @@ inlineQuery :: Name -- ^ Top-level variable name which has 'Relation' ty
-> Q [Dec] -- ^ Result declarations
inlineQuery relVar rel config sufs qns = do
(p, r) <- reifyRelation relVar
unsafeInlineQuery (return p) (return r) (sqlFromRelationWith rel config . showsQuerySuffix sufs $ "") (varCamelcaseName qns)
unsafeInlineQuery (return p) (return r)
(relationalQuerySQL config rel sufs)
(varCamelcaseName qns)