persistent-hssqlppp-0.1: Declare Persistent entities using SQL SELECT query syntax

Database.Persist.HsSqlPpp

Synopsis

Documentation

type Query = (QueryExpr, EntityDef)Source

(SQL query text, entity definition)

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

parseEntitySource

Arguments

:: FilePath

File name to use in error messages

-> String

Declaration text

-> Either String Query 

Parse SQL entity declaration

selectFromQuerySource

Arguments

:: 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

selectFromQuery'Source

Arguments

:: 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].

checkSQLSource

Arguments

:: [String]

Allowed table names

-> String

SQL query

-> Either String QueryExpr 

Check if given SQL query is safe SELECT query