Îõ³h*JeG’      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘ 0.7.0.0  Safe-Inferred %>Àäéü 1 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&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-persistenceÛIf True, the GenericPersistence functions will commit the transaction after each operation.generic-persistencethe transaction modegeneric-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 %>Àäéü Zgeneric-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, compound 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..generic-persistence1Returns True if the primary key field for a type a$ is autoincremented by the database./generic-persistence7Returns Just index of the primary key field for a type a?. if the type has no primary key field, Nothing is returned.0generic-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.1generic-persistenceÍA convenience function: returns the name of the column for a field of a type a.8generic-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(+)*,-.1&'%2/0(+)*,-.1'&%2/0 Safe-Inferred %>ÀäéüP <=>SU?@ABCDEFGHIJKVOLTMNP9:;QR <=>SU?@ABCDEFGHIJKVOLTMNP9:;QR ?3@2A4B4C4D4E4F4G4H4I4P1 Safe-Inferred %>Àäéü L Xgeneric-persistence‡A type alias for mapping a Haskell field type to a SQL column type. this type can be used to define custom mappings for field types.Ygeneric-persistence0An 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.ageneric-persistenceÃA function that returns an SQL count 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.bgeneric-persistenceÄA function that returns an SQL delete statement for an entity. Type a must be an instance of Entity.cgeneric-persistenceÏA function that returns an SQL create table statement for an entity type. Type a must be an instance of Entity.dgeneric-persistenceÍA function that returns the column type for a field of an entity. The function takes a column type mapping function as parameter. This function is used to map Haskell field types to SQL column types.egeneric-persistenceåThe default mapping for SQLite databases. This mapping is used when no custom mapping is provided.fgeneric-persistenceçThe default mapping for Postgres databases. This mapping is used when no custom mapping is provided.ggeneric-persistenceÂThis function generates a DROP TABLE statement for an entity type.-\^_]`abcgd<=>U?@ABCDEFGHIJKOLMNP9:;QR YZ[efX-\^_]`abcgd<=>U?@ABCDEFGHIJKOLMNP9:;QR YZ[efX Safe-Inferred %>Àäéü6˜hgeneric-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 operationsmgeneric-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.ngeneric-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 a tiny query dsl based on infix operators.ogeneric-persistence7This function retrieves the number of 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 the number of all matching entities. The <Ê is typically constructed using a tiny query dsl based on infix operators.pgeneric-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.qgeneric-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 reflectionrgeneric-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 deprecated: use upsert instead•generic-persistence†A function that commits a transaction if the connection is in auto commit mode. The function takes an HDBC connection as parameter.sgeneric-persistence¹A function that explicitely inserts an entity into a database. The function takes an HDBC connection and an entity as parameters. The entity, as retrieved from the database, is returned as a Right value if the entity was successfully inserted. (this allows to handle automatically updated fields like auto-incremented primary keys) If the entity could not be inserted, a Left value is returned, containing a PersistenceException.vgeneric-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.wgeneric-persistenceA function that explicitely updates an entity in a database. The function takes an HDBC connection and an entity as parameters.xgeneric-persistenceÙA function that updates a list of entities in a database. The function takes an HDBC connection and a list of entities as parameters. The update-statement is compiled only once and then executed for each entity.ygeneric-persistenceøA function that deletes an entity from a database. The function takes an HDBC connection and an entity as parameters.zgeneric-persistence…A function that deletes an entity from a database by its id. The function takes an HDBC connection and an entity id as parameters.{generic-persistence™A function that deletes a list of entities from a database by their ids. The function takes an HDBC connection and a list of entity ids as parameters.|generic-persistenceÛA function that deletes a list of entities from a database. The function takes an HDBC connection and a list of entities as parameters. The delete-statement is compiled only once and then executed for each entity.}generic-persistence«set up a table for a given entity type. The table is dropped (if existing) and recreated. The function takes an HDBC connection and a column type mapping as parameters.–generic-persistenceA function that returns the primary key value of an entity as a SqlValue. The function takes an HDBC connection and an entity as parameters.~generic-persistence!an alias for a simple quasiqouter€generic-persistenceÆThese instances are needed to make the Convertible type class work with Enum types out of the box. This is needed because the Convertible type class is used to convert SqlValues to Haskell types.Ïmnop~rqsvwxyz|{}efYZ[  (+)*,-.&%12hijkl<=>?@ABCDEFGHIJKOLMP9:;QR0utÏmnop~rqsvwxyz|{}efYZ[  (+)*,-.&%12hijkl<=>?@ABCDEFGHIJKOLMP9:;QR0ut Safe-Inferred %>ÀäéüE „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Ð 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 deprecated: use upsert instead‰generic-persistence¶A function that upserts an entity into 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?@ABCDEFGHIJKOLMP9:;QR ΄…†‡~ˆ‰Š‹ŒŽ‘}efYZ[  (+)*,-.&%12hijkl<=>?@ABCDEFGHIJKOLMP9:;QR  Safe-Inferred %>ÀäéüEþØ„…†‡~ˆ‰Š‹ŒŽ‘}efYZ[  (+)*,-.&%12hijkl<=>?@ABCDEFGHIJKOLMP9:;QR   Ø„…†‡~ˆ‰Š‹ŒŽ‘}efYZ[  (+)*,-.&%12hijkl<=>?@ABCDEFGHIJKOLMP9:;QR     Safe-Inferred %>ÀäéüG—˜™š›œžŸ   !"#$%&&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl mnopqrstuvwxyz{|}~€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–€‚ƒ…„†‰Š‹ŒŽ—˜ ™š›œ  ž Ÿ   ¡ ¢ £ ¤¥#generic-persistence-0.7.0.0-inplaceDatabase.GP.Query Database.GPDatabase.GP.ConnDatabase.GP.TypeInfoDatabase.GP.EntityDatabase.GP.SqlGenerator"Database.GP.GenericPersistenceSafeDatabase.GP.GenericPersistencegeneric-persistenceDatabaseGPPaths_generic_persistencebaseGHC.BaseNonEmptyHDBC-2.4.0.4-302ac8e5Database.HDBC.SqlValueSqlValuetoSqlfromSqlDatabase.HDBC.Types disconnectcommitrollbackrunRawrunDatabase.HDBC.UtilswithTransaction quickQuery:|rsrc-pl-0.4.0.0-08dbcfb2 Data.Pool withResourceConnectionPool TxHandling AutoCommitExplicitCommitConnconnectcreateConnPool$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$fShowSortOrderColumnTypeMappingPostgresSQLite insertStmtFor upsertStmtForinsertReturningStmtFor updateStmtForselectFromStmt countStmtFor deleteStmtForcreateTableStmtFor columnTypeFordefaultSqliteMappingdefaultPostgresMappingdropTableStmtForPersistenceExceptionEntityNotFoundDuplicateInsert DatabaseError NoUniqueKey selectByIdselectcountentitiesFromRowsupsertpersistinsertremoveAutoIncIdFieldhandleDuplicateInsert insertManyupdate updateManydelete deleteByIddeleteManyById deleteMany setupTablesql$fConvertibleaSqlValue$fConvertibleSqlValuea$fShowPersistenceException$fEqPersistenceException$fExceptionPersistenceException withWConn IConnection GHC.Generics:*:commitIfAutoCommitidValueversion getBinDir getLibDir getDynLibDir getDataDir getLibexecDirgetDataFileName getSysconfDir