- type Query = (QueryExpr, EntityDef)
- persistSql :: QuasiQuoter
- persistSqlFile :: FilePath -> Q [Exp]
- parseEntityFromFile :: FilePath -> IO (Either String Query)
- parseEntity :: FilePath -> String -> Either String Query
- selectFromQuery :: forall m a. (MonadControlIO m, PersistEntity a) => QueryExpr -> [Filter a] -> SqlPersist m (Either String [a])
- selectFromQuery' :: MonadControlIO m => [String] -> String -> SqlPersist m (Either String ([ColumnName], [[PersistValue]]))
- checkSQL :: [String] -> String -> Either String QueryExpr
Documentation
persistSql :: QuasiQuoterSource
Quasi-quoter which parses SQL SELECT queries. Example input:
SELECT family, salary FROM employee; -------------------- family String salary Int
NB: entity name will be "Undefined", so you'll need to use record update syntax to set name your want, e.g. entity {entityName = "Query"}.
persistSqlFile :: FilePath -> Q [Exp]Source
Load entity declaration from file containing SQL query. TH version.
parseEntityFromFile :: FilePath -> IO (Either String Query)Source
Load entity declaration from file containing SQL query
Parse SQL entity declaration
:: forall m a . (MonadControlIO m, PersistEntity a) | |
=> QueryExpr | SQL query |
-> [Filter a] | Filters |
-> SqlPersist m (Either String [a]) |
Select list of records from DB using given SQL query
:: MonadControlIO m | |
=> [String] | Names of allowed tables |
-> String | SQL query |
-> SqlPersist m (Either String ([ColumnName], [[PersistValue]])) |
Select list of records from DB using given SQL SELECT query. Query is checked for safety (arbitrary function calls, complex expressions, etc are not permitted). Each row will be represented as [PersistValue].