Îõ³h)> :øˆ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ 0.6.0  Safe-Inferred %=?ãèû + generic-persistenceA pool of connections.generic-persistenceÏThis module defines a wrapper around an HDBC IConnection. Using this wrapper 2 simplifies the signature of the functions in the   Ò module. It allows to use any HDBC connection without having to define a new function for each connection type. It also provides additional attributes to the connection, like the database type and the implicit commit flag. These attributes can be used to implement database specific functionality, modify transaction behaviour, etc.ŽThis code has been inspired by the HDBC ConnectionWrapper and some parts have been copied verbatim from the HDBC Database.HDBC.Types module.æThis module also defines a ConnectionPool type, which provides basic connection pooling functionality.%A wrapper around an HDBC IConnection.generic-persistenceÛIf True, the GenericPersistence functions will commit the transaction after each operation.generic-persistenceThe wrapped connectiongeneric-persistence&a smart constructor for the Conn type.ˆgeneric-persistence.allows to execute a function that requires an ‰ argument on a .generic-persistenceCreates a connection pool.generic-persistenceÀmanually implement the IConnection type class for the Conn type.generic-persistencethe transaction mode generic-persistencethe connection stringgeneric-persistenceÄa function that takes a connection string and returns an IConnectiongeneric-persistence3the time (in seconds) to keep idle connections opengeneric-persistence.the maximum number of connections to keep opengeneric-persistencethe resulting connection pool      Safe-Inferred %=?èû Ugeneric-persistenceÊA data type holding meta-data about a type. The Phantom type parameter aÝ ensures type safety for reflective functions that use this type to create type instances. generic-persistence×this function is a smart constructor for TypeInfo objects. It takes a value of type a and returns a `TypeInfo a` object. If the type has no named fields, an error is thrown. If the type has more than one constructor, an error is thrown.     Safe-Inferred%1<=?Úèûæ *generic-persistence§This is the Entity class. It is a type class that is used to define the mapping between a Haskell product type in record notation and a database table. The class has a default implementation for all methods. The default implementation uses the type information to determine a simple 1:1 mapping.ÿThat means that - the type name is used as the table name and the - field names are used as the column names. - A field named ' lowercasetypeName%ID' is used as the primary key field.ÖThe default implementation can be overridden by defining a custom instance for a type.Please note the following constraints, which apply to all valid Entity type, but that are not explicitely encoded in the type class definition:3The type must be a product type in record notation.+The type must have exactly one constructor.ÏThere must be single primary key field, compund primary keys are not supported.+generic-persistence+Converts a database row to a value of type a.,generic-persistenceConverts a value of type a to a database row.-generic-persistence5Returns the name of the primary key field for a type a..generic-persistenceÉReturns a list of tuples that map field names to column names for a type a./generic-persistence)Returns the name of the table for a type a.0generic-persistence1Returns True if the primary key field for a type a$ is autoincremented by the database.1generic-persistence7Returns Just index of the primary key field for a type a?. if the type has no primary key field, Nothing is returned.2generic-persistence”returns the index of a field of an entity. The index is the position of the field in the list of fields of the entity. If no such field exists, an error is thrown. The function takes an field name as parameters, the type of the entity is determined by the context.3generic-persistenceÍA convenience function: returns the name of the column for a field of a type a.:generic-persistenceÂThis instance is the most interesting one. It splits the list of Òs into two parts, one for the first field and one for the rest. Then it uses the 'Í instance for the first field to convert the first part of the list and the 'þ instance for the rest of the fields to convert the second part of the list. Finally, it combines the two results using the Š constructor. https://stackoverflow.com/questions/75485429/how-to-use-ghc-generics-to-convert-from-product-data-types-to-a-list-of-sqlvalue/75485650#75485650*-+,./03()'412*-+,./03)('412 Safe-Inferred %=?èûA >?@UWABCDEFGHIJKLMXQNVOPR;<=ST >?@UWABCDEFGHIJKLMXQNVOPR;<=ST A3B2C4D4E4F4G4H4I4J4K4R1 Safe-Inferred %=?ãèûZgeneric-persistence/An enumeration of the supported database types.]generic-persistenceÚThis module defines some basic SQL statements for Record Data Types that are instances of *ì. The SQL statements are generated using Haskell generics to provide compile time reflection capabilities.ÄA function that returns an SQL insert statement for an entity. Type a§ must be an instance of Data. The function will use the field names of the data type to generate the column names in the insert statement. The values of the fields will be used as the values in the insert statement. Output example: INSERT INTO Person (id, name, age, address) VALUES (123456, Alice, 25, "123 Main St");_generic-persistenceÄA function that returns an SQL update statement for an entity. Type a must be an instance of Entity.`generic-persistenceÄA function that returns an SQL select statement for an entity. Type a must be an instance of Entity. The function takes a where clause expression as parameter. This expression is used to filter the result set.cgeneric-persistenceÿA function that returns the column type for a field of an entity. TODO: Support other databases than just SQLite and Postgres.egeneric-persistenceOracle | MSSQL | MySQL(]^_`abdc>?@WABCDEFGHIJKLMQNOPR;<=STZ[\(]^_`abdc>?@WABCDEFGHIJKLMQNOPR;<=STZ[\ Safe-Inferred %=?ãèû+Õggeneric-persistenceéThis is the "safe" version of the module Database.GP.GenericPersistence. It uses Either to return errors.ÝThis module defines RDBMS Persistence operations for Record Data Types that are instances of Data1. I call instances of such a data type Entities.‰The Persistence operations are using Haskell generics to provide compile time reflection capabilities. HDBC is used to access the RDBMS.7exceptions that may occur during persistence operationslgeneric-persistence±A function that retrieves an entity from a database. The function takes entity id as parameter. If an entity with the given id exists in the database, it is returned as a Just value. If no such entity exists, Nothing is returned. An error is thrown if there are more than one entity with the given id.mgeneric-persistence-This function retrieves all entities of type aÐ that match some query criteria. The function takes an HDBC connection and a > as parameters. The type a… is determined by the context of the function call. The function returns a (possibly empty) list of all matching entities. The >Ì is typically constructed using any tiny query dsl based on infix operators.ngeneric-persistenceÇThis function converts a list of database rows, represented as a `[[SqlValue]]` to a list of entities. The function takes an HDBC connection and a list of database rows as parameters. The type a¤ is determined by the context of the function call. The function returns a (possibly empty) list of all matching entities. The function is used internally by  retrieveAll and retrieveAllWhereß. But it can also be used to convert the result of a custom SQL query to a list of entities.ogeneric-persistenceµA function that persists an entity to a database. The function takes an HDBC connection and an entity as parameters. The entity is either inserted or updated, depending on whether it already exists in the database. The required SQL statements are generated dynamically using Haskell generics and reflection‹generic-persistence†A function that commits a transaction if the connection is in auto commit mode. The function takes an HDBC connection as parameter.pgeneric-persistence>A function that explicitely inserts an entity into a database.rgeneric-persistenceÛA function that inserts a list of entities into a database. The function takes an HDBC connection and a list of entities as parameters. The insert-statement is compiled only once and then executed for each entity.sgeneric-persistence?@ABCDEFGHIJKLMQNOR;<=ST2qÊlmnxoprstuvwZ[\  *-+,./0('34 ghijk>?@ABCDEFGHIJKLMQNOR;<=ST2q Safe-Inferred %=?èû9" ~generic-persistenceÝThis module defines RDBMS Persistence operations for Record Data Types that are instances of Data1. I call instances of such a data type Entities.‰The Persistence operations are using Haskell generics to provide compile time reflection capabilities. HDBC is used to access the RDBMS.±A function that retrieves an entity from a database. The function takes entity id as parameter. If an entity with the given id exists in the database, it is returned as a Just value. If no such entity exists, Nothing is returned. An error is thrown if there are more than one entity with the given id.generic-persistence-This function retrieves all entities of type aÓ from a database. The function takes an HDBC connection as parameter. The type aþ is determined by the context of the function call. retrieveAll :: forall a. (Entity a) => Conn -> IO [a] retrieveAll conn = do eitherExRow <- GpSafe.retrieveAll @a conn case eitherExRow of Left ex -> throw ex Right rows -> pure rows-This function retrieves all entities of type aÐ that match some query criteria. The function takes an HDBC connection and a > as parameters. The type a… is determined by the context of the function call. The function returns a (possibly empty) list of all matching entities. The >Ì is typically constructed using any tiny query dsl based on infix operators.€generic-persistencešA function that constructs a list of entities from a list of rows. The function takes an HDBC connection and a list of rows as parameters. The type až is determined by the context of the function call. The function returns a list of entities. This can be useful if you want to use your own SQL queries.generic-persistenceµA function that persists an entity to a database. The function takes an HDBC connection and an entity as parameters. The entity is either inserted or updated, depending on whether it already exists in the database. The required SQL statements are generated dynamically using Haskell generics and reflection‚generic-persistence>A function that explicitely inserts an entity into a database.ƒgeneric-persistenceÛA function that inserts a list of entities into a database. The function takes an HDBC connection and a list of entities as parameters. The insert-statement is compiled only once and then executed for each entity.„generic-persistence?@ABCDEFGHIJKLMQNOR;<=STÊ~€x‚ƒ„…†‡wZ[\  *-+,./0('34 ghijk>?@ABCDEFGHIJKLMQNOR;<=ST Safe-Inferred%=?èû9øÔ~€x‚ƒ„…†‡wZ[\  *-+,./0('34 ghijk>?@ABCDEFGHIJKLMQNOR;<=ST   Ô~€x‚ƒ„…†‡wZ[\  *-+,./0('34 ghijk>?@ABCDEFGHIJKLMQNOR;<=ST    Safe-Inferred %=?èû:㎑’“”•   !"#$%&&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklm nopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ€‚ƒ…†‡ˆ‰‘’ “”•– — ˜ ™ š › œ  žŸ!generic-persistence-0.6.0-inplaceDatabase.GP.Query Database.GPDatabase.GP.ConnDatabase.GP.TypeInfoDatabase.GP.EntityDatabase.GP.SqlGenerator"Database.GP.GenericPersistenceSafeDatabase.GP.GenericPersistencegeneric-persistenceDatabaseGPPaths_generic_persistencebaseGHC.BaseNonEmpty:|HDBC-2.4.0.4-4d996970Database.HDBC.SqlValueSqlValuetoSqlfromSqlDatabase.HDBC.Types disconnectcommitrollbackrunRawrunDatabase.HDBC.UtilswithTransaction quickQueryrsrc-pl-0.4.0.0-0a51d803 Data.Pool withResourceConnectionPool TxHandling AutoCommitExplicitCommitConn$sel:implicitCommit:Conn$sel:connection:ConnconnectcreateConnPool$fIConnectionConn HasSelectors selectorsHasConstructorgenericConstrNameTypeInfo$sel:constructorName:TypeInfo$sel:fieldNames:TypeInfo$sel:fieldTypes:TypeInfotypeInfo$fHasConstructorM1$fHasConstructorM10$fHasSelectorsFUN:*:$fHasSelectorsFUNM1$fHasSelectorsFUNM10$fHasSelectorsFUNM11GFromRowGToRowgtoRowEntityfromRowtoRowidFieldfieldsToColumns tableName autoIncrementmaybeIdFieldIndex fieldIndex columnNameFormaybeFieldTypeFor $fGToRowkM1 $fGToRowk:*: $fGToRowkK1 $fGFromRowkM1 $fGFromRowkK1$fGFromRowTYPE:*: SortOrderASCDESCWhereClauseExprFieldfield&&.||.=.>.<.>=.<=.<>.likebetweenin'isNullnot' allEntriesbyId byIdColumnsqlFunorderBylimit limitOffsetwhereClauseExprToSqlidColumnwhereClauseValuesparams$fShowSortOrderPostgresSQLite insertStmtForinsertReturningStmtFor updateStmtForselectFromStmt deleteStmtForcreateTableStmtFor columnTypeFordropTableStmtFor$fShowDatabase $fEqDatabasePersistenceExceptionEntityNotFoundDuplicateInsert DatabaseError NoUniqueKey selectByIdselectentitiesFromRowspersistinserthandleDuplicateInsert insertManyupdate updateManydelete deleteMany setupTableForsql$fConvertibleaSqlValue$fConvertibleSqlValuea$fShowPersistenceException$fEqPersistenceException$fExceptionPersistenceException withWConn IConnection GHC.Generics:*:commitIfAutoCommitidValueversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDirgetDataFileName getSysconfDir