Commit Graph

269 Commits

Author SHA1 Message Date
Felipe Lessa
4724560cb6 Fix more JOIN doc inaccuracies. 2015-05-12 12:56:11 -03:00
Felipe Lessa
88d0202000 Improve groupBy doc. 2015-05-12 12:51:47 -03:00
Felipe Lessa
b20fe09755 Fix valkey's documentation. 2015-05-12 12:39:38 -03:00
Felipe Lessa
5763a9d963 Fix comment about JOIN fixity. 2015-05-12 12:34:58 -03:00
Felipe Lessa
e4ccc4ecdc Fix markup for backticks ` and double quotes " on Haddocks.
Actually, the old form of backticks works on my Haddock, but somehow
doesn't on Hackage's Haddock.  This second form is still valid although
ugly, and works on my Haddock as well.  From reading Haddock's
documentation and source code, I don't think there's a canonical way of
writing this markup.
2015-05-12 12:32:45 -03:00
Felipe Lessa
a79144326a Merge pull request #97 from Philonous/joins
fix rendering of joins
2015-04-27 17:01:11 -03:00
Philipp Balzarek
603023a579 don't match on clauses with cross joins 2015-04-21 19:37:36 +02:00
Philipp Balzarek
b0b40a07ff make join constructors left-associative 2015-04-21 18:52:26 +02:00
Philipp Balzarek
da40706163 fix rendering of joins 2015-04-21 18:51:32 +02:00
Felipe Lessa
2f70220d55 Merge remote-tracking branch 'aherrmann/pr_coalesce_subquery' 2015-04-10 23:29:38 -03:00
Felipe Lessa
5b33da2c2d Merge remote-tracking branch 'frontrowed/add-lower' 2015-04-10 23:25:20 -03:00
Felipe Lessa
e8d85285cb A bunch of cleanups (ping @albertov). 2015-04-10 23:22:19 -03:00
Alexandr Kurilin
b46c52d7b2 Add support for lower() function 2015-04-03 16:29:17 -07:00
Alberto Valverde
48cae5396e allow returning custom id columns from queries if they're not composite 2015-04-01 19:06:10 +02:00
Andreas Herrmann
f22a11d989 Fix coalesce/coalesceDefault for sub-queries
If COALESCE has a sub-query as an argument, then this sub-query needs to remain
wrapped in an extra pair of parentheses.
2015-02-27 23:12:32 +01:00
Alberto Valverde
9efc909f49 Moved non-id/composite pk tests to their corresponding specs and marked failing tests as "pending" 2015-01-05 17:35:00 +01:00
Alberto Valverde
45295039e0 fixed most warnings. Implemented orderBy for composite pks. Added a failing test for returning a composite pk from a query 2014-12-30 12:33:36 +01:00
Alberto Valverde
923a973abe Removed (some) warnings 2014-12-29 18:52:01 +01:00
Alberto Valverde
ad409312cf Support non-id primary key joins with columns not declared as ForeignKey but of ParentId type 2014-12-29 17:49:08 +01:00
Alberto Valverde
477c0a4c21 handle non-id/composite primary keys on ==. and !=. 2014-12-29 15:05:57 +01:00
Alberto Valverde
1f80074b6e Revert "Revert "custom primary keys (not composite, yet) supported on projections""
This reverts commit 761ef03b03.
2014-12-24 05:27:10 +01:00
Alberto Valverde
761ef03b03 Revert "custom primary keys (not composite, yet) supported on projections"
This reverts commit 3f31f41a71.
2014-12-23 23:57:03 +01:00
Alberto Valverde
3f31f41a71 custom primary keys (not composite, yet) supported on projections 2014-12-23 21:24:41 +01:00
Alberto Valverde
cc4844167f Implemented support for custom/composite primary keys 2014-12-23 14:13:07 +01:00
Josh Berman
8579010409 INSERT INTO SELECT typo 2014-11-17 17:19:45 +02:00
Felipe Lessa
40c4528540 Bump version to 2.1.2. 2014-11-03 12:27:46 -02:00
Felipe Lessa
88553f657d Punctuation. 2014-11-03 12:27:25 -02:00
Paul Berens
ebe9185ef2 Test improvement and documentation improvements 2014-11-02 14:50:30 -08:00
Paul Berens
d690e0b425 Implement CASE support
* This seems to work but I don't have in-depth tests yet
 * I seem to still have some oddity here and there which needs to be
 nailed down
 * This only implements the "full" CASE syntax, not the simplified, and
 it makes ELSE mandatory, (its optional with CASE)
2014-11-02 01:31:54 -07:00
Michael Snoyman
05fbbba86a Support for persistent 2.0.8 2014-09-28 07:05:41 +03:00
Michael Snoyman
bcb620026f Support persistent 2.0.5 2014-09-21 21:34:09 +03:00
Michael Snoyman
2af4aaf37d Fix for #74 2014-09-18 08:40:05 +03:00
Michael Snoyman
4febf46c6a Merge branch 'persistent2' of github.com:fpco/esqueleto
Conflicts:
	esqueleto.cabal
	src/Database/Esqueleto.hs
2014-09-08 09:05:57 +03:00
Michael Snoyman
30964d950d More persistent2 updates 2014-08-27 11:27:36 +03:00
Felipe Lessa
fb36a603f8 isNull doesn't exist :). 2014-07-16 17:14:05 -03:00
Felipe Lessa
ba577a0111 Functor Value. 2014-07-12 12:00:54 -03:00
Felipe Lessa
bfdb140e46
Bump version to 1.4.3. 2014-07-12 00:27:23 -03:00
Mitchell Rosen
22f03c2e39 change coalesceDefault argument order 2014-07-11 19:51:01 -07:00
Mitchell Rosen
e735378f90 added coalesce/coalesceDefault functions 2014-07-11 16:03:04 -07:00
Felipe Lessa
e91c625ff7 Small doc improvement. 2014-07-07 23:55:38 -03:00
Erik de Castro Lopo
41698518c9 Rename keyE to valJ and fix implementation.
As Felipe points out in the PR comments, the implementation can be
simplified to "val . unValue" but the type signature on the function
still prevents anything non-sensical happening.

See: https://github.com/prowdsponsor/esqueleto/pull/69
2014-07-08 10:47:44 +10:00
Erik de Castro Lopo
0b830771ea Add function keyE.
Give a value, keyE lifts the Key for that value into the query expression.

    keyE :: Esqueleto query expr backend =>
            Value (Key entity) -> expr (Value (Key entity))
2014-07-07 19:52:21 +10:00
Michael Snoyman
2685cdb7f7 Merge branch 'master' of github.com:meteficha/esqueleto into HEAD
Conflicts:
	esqueleto.cabal
	src/Database/Esqueleto/Internal/Sql.hs
2014-05-26 16:34:34 +03:00
Felipe Lessa
46fa0cafcf Export an unValue function. 2014-05-08 10:55:08 -03:00
Felipe Lessa
b04be7d615 Small doc improvements. 2014-05-08 10:47:51 -03:00
Felipe Lessa
3bd5c8506a Allow esqueleto's functions to be used on top of transformers.
Instead of using SqlPersistT, now it uses MonadSqlPersist.
2014-04-23 11:42:07 -03:00
Michael Snoyman
d47a1a00e3 resourcet 1.1 2014-04-18 14:53:50 +03:00
Felipe Lessa
ab9e57b2d0 Export veryUnsafeCoerceSqlExprValueList (fixes #62). 2014-04-14 14:57:48 -03:00
Felipe Lessa
466de1f96b Add "since" to rand's doc. 2014-04-08 19:31:51 -03:00
Erik de Castro Lopo
d37331e04d Implement orderBy[rand] modifier. 2014-04-09 05:56:25 +10:00
David McBride
a21e930259 Conduit no longer exports resourcet related functions. 2014-04-02 11:52:23 -04:00
Felipe Lessa
67522cecbc
Bump version to 1.3.6. 2014-04-02 11:45:32 -03:00
Felipe Lessa
3ed5930063 Merge pull request #54 from tlaitinen/master
unsafeSqlExtractSubField to support EXTRACT subfield FROM field-syntax
2014-04-02 11:39:23 -03:00
Tero Laitinen
69b4be6e37 unsafeSqlExtractSubField to support EXTRACT subfield FROM field-syntax 2014-04-02 17:30:28 +03:00
Felipe Lessa
5192a2b98e Fix typo on doc (closes #36). 2014-03-04 09:51:50 -03:00
Felipe Lessa
0de8242634 Use persistent 1.3+ new limit/offset func (closes #35).
This code was actually written by @gbwey and it's being
manually merged with some changes by me.
2014-03-04 09:25:14 -03:00
Felipe Lessa
9fdf296367 Merge pull request #31 from jcristovao/master
sum function does not return the same type it receives
2014-03-04 09:08:34 -03:00
Felipe Lessa
f04e277a2d Rewrite insertSelect so that it properly escapes names (fixes #47). 2014-03-04 09:02:18 -03:00
Michael Snoyman
7f6ae061da persistent2 2014-01-16 08:24:43 +02:00
Tero Laitinen
f3ff39e898 export SqlSelect class functions to allow creating instances to select more than 16 fields 2013-11-18 14:40:34 +02:00
João Cristóvão
753e4bccac Added num class restriction to random, round_, floor_. 2013-09-19 09:30:16 +01:00
João Cristóvão
0033050806 Merge branch 'master' of github.com:meteficha/esqueleto 2013-09-15 21:57:04 +01:00
Michael Snoyman
f2c2a4ff2e Fix Haddocks 2013-09-15 14:13:49 +03:00
Felipe Lessa
33b1fafc2d Thread IdentState through subqueries (fixes #28).
There used to be name clashes if a subquery referenced
an entity that was already being used on the outer query.
Now we thread the outer query's IdentState to its subqueries,
which use it instead of initialIdentState.

Note that clashes still may occur between subqueries of
a query, but I think that's harmless.
2013-09-15 04:16:35 -03:00
Felipe Lessa
c5c76959bd Move public insertSelect API to Language module. 2013-09-15 04:03:40 -03:00
Felipe Lessa
a7d8c99213 Re-order exports related to insertSelect. 2013-09-15 03:52:10 -03:00
Felipe Lessa
53402d726f Add some documentaion to SqlExpr. 2013-09-15 03:27:12 -03:00
Felipe Lessa
e8013a93d4 Saner implementation of existsHelper. 2013-09-15 02:17:29 -03:00
João Cristóvão
161621cbd4 sum_ result type may not be the same as the parameters type. 2013-09-11 10:48:12 +01:00
Danny B
d6d528d5a9 Fix underscore. 2013-08-09 14:56:19 +11:00
Danny B
452861de78 Fix comma. 2013-08-09 09:06:48 +11:00
Danny B
e77e056f5b Handle NULL result in avg_ too. 2013-08-08 16:46:01 +11:00
Danny B
068ec9b1ae Proper NULL handling in max_, min_ and sum_.
- return expr (Value (Maybe a))
- add joinV to join nested Maybes in an expr
2013-08-08 15:51:31 +11:00
Danny B
83dc4a433c Make max_, min_ and sum_ less general. 2013-08-07 15:27:29 +11:00
Sam Anklesaria
3641f36326 added tests for math and aggregation functions 2013-07-03 15:46:22 +09:00
Sam Anklesaria
4377f2cffa fixed a typo 2013-07-02 19:47:18 +09:00
Sam Anklesaria
024537b592 Merge branch 'master' of git://github.com/meteficha/esqueleto 2013-07-02 19:40:28 +09:00
Sam Anklesaria
30c321ee03 common math and aggregation sql functions 2013-07-02 19:39:17 +09:00
Felipe Lessa
66e67e1cff Final touchs on docs. 2013-07-01 11:06:53 -03:00
Sam Anklesaria
dc5baefd48 No more MPTCs, added documentation 2013-06-30 11:44:24 +09:00
Sam Anklesaria
ee8656adf0 insert select statements 2013-06-22 23:48:08 +09:00
Felipe Lessa
d056545c3e Bump version to 1.2.2. 2013-05-20 12:35:54 -03:00
Takahiro HIMURA
893f1cd54b Add HAVING support. 2013-05-19 08:21:52 +09:00
Felipe Lessa
f0ae243f5f Fix support for "return ()" inside a select. 2013-05-17 14:32:33 -03:00
Felipe Lessa
f6969d5971 Avoid double commas (fixes test suite). 2013-05-17 14:23:07 -03:00
Felipe Lessa
1e633a8dd9 Upgrade to persistent 1.2 and bump version to 1.2.
Note that version 1.1 was skipped for the sake of bringing
esqueleto's version to parity with persistent's.
2013-04-29 18:21:44 -03:00
Felipe Lessa
fd75d3014a Add newline to the end of Sql.hs. 2013-04-09 11:37:54 -03:00
azafeh
d294caa2ac mais instâncias de tuple 2013-04-08 22:40:20 -03:00
Mitsutoshi Aoe
b6fe3c0bb6 Do not discard vals in count 2013-03-08 10:09:30 +09:00
Mitsutoshi Aoe
0889709403 Add support for COUNT(expr) 2013-03-07 20:04:43 +09:00
Felipe Lessa
51c08ed0e8 Add deleteCount and updateCount (fixes #10). 2013-02-12 13:09:30 -02:00
Felipe Lessa
745c5cd276 Allow complex ORDER BYs by correctly putting parenthesis. 2013-01-27 21:16:07 -02:00
Felipe Lessa
6d8b84c55c valList [] now works. 2013-01-27 17:28:00 -02:00
Felipe Lessa
aa2c207dd1 Add valkey helper (fixes #9). 2012-12-14 16:45:59 -02:00
Felipe Lessa
9db4408d7c Use persistent 1.1. 2012-12-14 12:12:05 -02:00
Felipe Lessa
8759774ede Doc typo. 2012-11-29 13:54:55 -02:00
Felipe Lessa
5514f68994 Support for IN and NOT IN. 2012-11-28 18:23:52 -02:00
Felipe Lessa
4769d30b18 Add support for EXISTS and NOT EXISTS. 2012-11-28 18:23:07 -02:00
Danny B
97400eb9ad Make queries *without* groupBy work again. 2012-09-24 00:51:22 +11:00
Danny B
cc88aa701e Minor fixes. 2012-09-24 00:28:35 +11:00
Danny B
8a79bdaad1 Add some tuple magic to groupBy.
Now you can say things like:
groupBy (foo ^. FooId, foo ^. FooName, Bar ^. BarName)
instead of:
groupBy $ foo ^. Fooid
groupBy $ foo ^. FooName
groupBy $ Bar ^. BarName
2012-09-23 23:11:24 +11:00
Danny B
3c932f5a79 Add support for GROUP BY. 2012-09-23 06:07:01 +11:00
Felipe Lessa
94b19267ee New functions limit and offset. 2012-09-09 14:28:28 -03:00
Felipe Lessa
5a0974f4c0 New text-related functions like, (%), concat_ and (++.). 2012-09-09 12:20:15 -03:00
Felipe Lessa
7df5fe0edd New function unsafeSqlFunction. 2012-09-09 10:44:55 -03:00
Felipe Lessa
6f1cbe36a7 New function unsafeSqlValue. 2012-09-09 10:30:57 -03:00
Felipe Lessa
ef771c6eda Provide a veryUnsafeCoerceSqlExprValue function that may be useful. 2012-09-09 10:26:56 -03:00
Felipe Lessa
c8a96db9da Clarify that writing portable SQL is not one of our goals. 2012-09-09 10:22:32 -03:00
Felipe Lessa
65e7e67247 Export binop as unsafeSqlBinOp. 2012-09-09 09:52:23 -03:00
Felipe Lessa
0aa3c23a75 New SqlEntity constraint synonym. 2012-09-09 09:47:38 -03:00
Felipe Lessa
b0329b05dc Use a bigger default chunk size when constructing the query.
The default is 112 bytes, or 56 characters.  With this commit we
start using 992 bytes, or 496 characters, which should be enough
to fit most queries without needing reallocations or memory copies.
2012-09-06 14:18:42 -03:00
Felipe Lessa
a5b93ff329 Typo. 2012-09-06 10:58:13 -03:00
Felipe Lessa
e2d73b49d9 Typo.
As always, found just after a Hackage release.
2012-09-06 10:54:33 -03:00
Felipe Lessa
326b2d45bf Silly typo. 2012-09-06 10:43:34 -03:00
Felipe Lessa
da6a669366 Add warning about unsupported JOINs to from's docs. 2012-09-06 10:40:39 -03:00
Felipe Lessa
4822172a42 Haddock fix. 2012-09-06 10:37:20 -03:00
Felipe Lessa
25f632398d Better top-level docs for internal modules. 2012-09-06 10:35:55 -03:00
Felipe Lessa
1286dc79b8 Better 'select' and 'delete' documentation. 2012-09-06 10:29:37 -03:00
Felipe Lessa
3b995ba46f Better documentation of Sql's internals. 2012-09-06 10:00:23 -03:00
Felipe Lessa
17a2cb65a9 Haddock fixes. 2012-09-06 09:49:14 -03:00
Felipe Lessa
1cb5c19288 Better 'from' documentation. 2012-09-06 09:46:08 -03:00
Felipe Lessa
271b5410da Typo. 2012-09-06 01:49:09 -03:00
Felipe Lessa
029aff837c Typo. 2012-09-06 01:48:25 -03:00
Felipe Lessa
f718be86da Instead of using rawSql's Single, use a new data type Value.
First of all, Value is a nicer name than Single.

However the main reason is to avoid error calls and to get better
feedback about the code from GHC.  Because of the GHC bug #6124,
we had many calls to 'error' just to avoid spurious warnings.  By
using data (instead of newtype) for Value we're able to avoid
them.  This commit removes *19* error calls from Sql.hs that GHC
is now able to prove that are unreachable.
2012-09-06 01:40:52 -03:00
Felipe Lessa
cc72ee9811 Misleading fixity declaration. 2012-09-06 01:28:06 -03:00
Felipe Lessa
077458ad56 Typos. 2012-09-06 01:27:34 -03:00
Felipe Lessa
bc21bac9ca A lot more docs. 2012-09-06 01:06:37 -03:00
Felipe Lessa
df63cd864b COUNT(*). 2012-09-05 23:18:56 -03:00
Felipe Lessa
0f677e9246 Add UPDATE support. 2012-09-05 23:09:02 -03:00
Felipe Lessa
f5c046775a Generalize types of numerical operations.
Persistent doesn't ask for Num and everything has
worked very well so far.  Not having a Num constraint
also allows those operations to work on Maybes.
2012-09-05 22:57:16 -03:00
Felipe Lessa
3e242d7b03 Use the table name as a base for a fresh identifier. 2012-09-05 20:54:38 -03:00
Felipe Lessa
3f2f1fdea7 Avoid a lot of redundant parenthesis.
Although this commit should not change the behaviour of any code,
it does make the resulting SQL a lot more pleasant to the eye.
2012-09-05 20:45:35 -03:00
Felipe Lessa
a29183028b New DELETE support. 2012-09-05 20:34:24 -03:00
Felipe Lessa
b67fcedfeb Allow queries to return (). 2012-09-05 20:34:03 -03:00
Felipe Lessa
c41a7dd464 Avoid using AS as much as possible. 2012-09-05 20:33:32 -03:00
Felipe Lessa
f84304deb8 Inline getConnection. 2012-09-05 19:19:28 -03:00
Felipe Lessa
dad271a75a Prettify LANGUAGE pragmas. 2012-09-05 19:16:28 -03:00
Felipe Lessa
9a24c7774c Allow SELECT DISTINCT queries as well. 2012-09-05 19:14:03 -03:00
Felipe Lessa
0c694e92a5 On collectOnClauses, match from clauses in the correct order.
Previously it tried matching on the right branch just after
matching on the current node, which means that on the default
right fixity everything was reversed.

Note: SQLite didn't give any error messages for this bug!
2012-09-05 16:53:55 -03:00
Felipe Lessa
c0f5993be7 Correctly parenthesize and put ON clauses. 2012-09-05 16:47:33 -03:00
Felipe Lessa
8973d650a4 Allow ON clauses on sub-JOINs. 2012-09-05 16:47:15 -03:00
Felipe Lessa
7bb68cc233 Allow any parenthesization of JOINs. 2012-09-05 15:55:59 -03:00
Felipe Lessa
1e19d8625b Implement JOIN and ON clauses. Also add (?.). 2012-09-05 15:38:14 -03:00
Felipe Lessa
80d60bb9b6 Avoid using capitalized "Esqueleto" when referring to the library. 2012-09-04 18:37:02 -03:00
Felipe Lessa
31b4b0669f orderBy, asc, desc. 2012-09-04 18:12:40 -03:00
Felipe Lessa
c601613162 isNothing, just, nothing. 2012-09-04 18:12:25 -03:00
Felipe Lessa
df8279b306 Re-export all of GenericSql from Esqueleto. 2012-09-04 01:01:56 -03:00
Felipe Lessa
bb7775b672 Create a separate sqlSelectColCount. 2012-09-04 00:45:16 -03:00
Felipe Lessa
57c3b403d5 Avoid undefined. 2012-09-04 00:29:39 -03:00
Felipe Lessa
dc6bcda8e4 Correctly consume connection resources. 2012-09-04 00:27:47 -03:00