An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

postgresql-query

[Index] [Quick Jump] Package maintainers For package maintainers and hackage trustees Candidates postgresql-query is a library for more simple query generation for PostgreSQL database. It is not an ORM (but contains some part of). It contains interpolating quasiquote for simple query generation. When you want to perform some complex SQL query using postgresql-simple you writing this query by hands like that: Well, this is not realy complex. Now what you need to perform the query is to paste parameters instead of this ? signs: Did you see the mistake? We forgot about ordering field. To perform this query we must Oups!. If we use Identifier "u.name" we will get "u.name" in our query which is just not right. Sql syntax assumes "u"."name" for this query. We can not use query parameter to paste optional field here. Next example is more complex: So much to write and so many chances to make a mistake. What if we could write this like: Much better! Quasiquote sqlExp has two way of interpolation: #{exp} - pastes inside query arbitrary value which type is instance of ToField typeclass. It performs correct strings escaping so it is not the same as stupid string interpolation. Dont worry about sql-injections when using it. ^{exp} - pastes inside query arbitrary value which type has instance of ToSqlBuilder typeclass. sqlExp returns SqlBuilder which has a Monoid instance and made for effective concatination (bytestring builder works inside). This quasiquote correctly handles string literals and quoted identifiers. It also removes line and block (even nested) sql comments from resulting query as well as sequences of space characters. You are free to write queries like or even sqlExp will remove all comments and will not interpolate inside string literals or quoted identifiers at all. If you have realy huge hardcore sql template you can It works just like Yesod's templates. You can use interpolation inside templates like inside sqlExp. Is absolutely the same as above. It just prepends sql/ and appends .sql to your string. If you agree to follow naming conventions you are welcome to use sqlExpFile.

Ecosystem
hackage.haskell.org
Latest Release
3.10.0
over 3 years ago
Versions
27
Downloads
17,458 total
Dependent Repos
15
Links
Registry hackage.haskell.org
Source Repository
JSON API View JSON
CodeMeta codemeta.json
Package Details
PURL pkg:hackage/postgresql-query
spec
License BSD-3-Clause
First Release about 11 years ago
Last Synced 6 days ago
Repository
Stars 3 on GitHub
Forks 1 on GitHub
Rankings on hackage.haskell.org
Downloads Top 8.9%