I am happy to announce release of Groundhog 0.3!
Groundhog is a library for high-level database access. It has support for
Sqlite, PostgreSQL, and a new MySQL backend. Advanced migration
capabilities allow you to precisely specify the schema description, fitting
it to an existing database, or creating a migration script for a new one.
Groundhog is not opinionated about schema and can bind your datatypes to a
relational model which may have composite keys, references across different
schemas, indexes, etc.
Changes:
* Novel mechanism for defining your own functions, operators, or other
expressions and combining them in a type-safe manner. The operators LIKE
and IN, which appeared in this version, are one-liners based on it. Now you
can write advanced queries compositionally without resorting to raw SQL.
For example:
project (upper (ZipCodeField `append` AddressField), NumberField *
(NumberField + (1 :: Int))) $ lower NameField `like` "jack%"
will be transformed into SQL query
SELECT upper(zipcode || address), number * (number + ?) FROM tablename
WHERE lower(name) like ?
* PostgreSQL backend got support for arrays and geometric datatypes.
* First release of MySQL backend (influenced by persistent-mysql).
* New class ConnectionManager helps to extract connections from pools,
application state, or other sources. Now both plain connections and pools
can be run with the same function runDbConn. In particular, this class
helps with integrating Groundhog into web applications.
* Support for savepoints (nested transactions).
* Schema qualified tables. The entities can be configured with a schema
parameter. It defines schema where the table, its triggers, indexes, and
other related database objects are stored. Schemas are respected both
during migration and when generating queries.
* Custom primary keys. A unique set of fields can be defined as a
constraint, index, or primary key. Composite primary keys are supported as
well.
* Configuration of reference clauses ON DELETE and ON UPDATE.
* New class SchemaAnalyzer exposes Groundhog functions for database
introspection. In future it can be used to build more powerful migration
tools, or generate datatypes from table definitions.
The full description of the configuration options is available at
http://hackage.haskell.org/packages/archive/groundhog-th/0.3.0/doc/html/Database-Groundhog-TH.html
Please see examples at
http://github.com/lykahb/groundhog/tree/master/examples.
If you want to integrate Groundhog into your application which is based on
Snap, Yesod, or just uses another monad to store connections, see this
example
http://github.com/lykahb/groundhog/blob/master/examples/monadIntegration.hs.
Although there are many new features in this release, Groundhog API is
mature enough to minimize the breaking changes. To migrate from Groundhog
2.* replace runSqliteConn/runPostgresqlConn/runSqlitePool/runPostgresqlPool
with runDbConn.
Special thanks to MightyByte who suggested to generalize connections and
helped to find the design, and to many others who gave their inspiring
feedback.
* http://github.com/lykahb/groundhog
* http://hackage.haskell.org/package/groundhog
* http://hackage.haskell.org/package/groundhog-th
* http://hackage.haskell.org/package/groundhog-mysql
* http://hackage.haskell.org/package/groundhog-postgresql
* http://hackage.haskell.org/package/groundhog-sqlite
Enjoy!
--
Regards,
Boris
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe