on dev help sign in
more docs
commit756a42704288a9c1f39e03225015a04a9f313497 authorEitan Chatav <eitan@Eitans-MacBook-Pro.local> dateFri 12 Apr 2019, 18:21 (8 years ago) parent622b021
8 files changed+77−17
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Logic.hs+11−1 squeal-postgresql/src/Squeal/PostgreSQL/Expression/Math.hs+10 squeal-postgresql/src/Squeal/PostgreSQL/Expression/Null.hs+10 squeal-postgresql/src/Squeal/PostgreSQL/Expression/Parameter.hs+10 squeal-postgresql/src/Squeal/PostgreSQL/Expression/Sort.hs+24−14 squeal-postgresql/src/Squeal/PostgreSQL/Expression/Text.hs+10 squeal-postgresql/src/Squeal/PostgreSQL/Expression/TextSearch.hs+1−1 squeal-postgresql/src/Squeal/PostgreSQL/Expression/Time.hs+1−1
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Logic.hs+11−1
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Expression.Logic
3+Description: Logical expressions
4+Copyright: (c) Eitan Chatav, 2019
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+Logical expressions and operators
9+-}
10+
111{-# LANGUAGE
212 DataKinds
313 , OverloadedStrings
@@ -20,7 +30,7 @@ import Squeal.PostgreSQL.Render
2030import Squeal.PostgreSQL.Schema
2131
2232-- | A `Condition` is an `Expression`, which can evaluate
23−-- to `true`, `false` or `null_`. This is because SQL uses
33+-- to `true`, `false` or `Squeal.PostgreSQL.Null.null_`. This is because SQL uses
2434-- a three valued logic.
2535type Condition outer commons grp schemas params from =
2636 Expression outer commons grp schemas params from ('Null 'PGbool)
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Math.hs+10
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Expression.Math
3+Description: Math expressions
4+Copyright: (c) Eitan Chatav, 2019
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+Mathematical functions and operators
9+-}
10+
111{-# LANGUAGE
212 DataKinds
313 , OverloadedStrings
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Null.hs+10
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Expression.Null
3+Description: Null
4+Copyright: (c) Eitan Chatav, 2019
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+Null values and null handling functions
9+-}
10+
111{-# LANGUAGE
212 DataKinds
313 , OverloadedStrings
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Parameter.hs+10
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Expression.Parameter
3+Description: Parameters
4+Copyright: (c) Eitan Chatav, 2019
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+Parameters, out-of-line data values
9+-}
10+
111{-# LANGUAGE
212 AllowAmbiguousTypes
313 , DataKinds
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Sort.hs+24−14
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Expression.Sort
3+Description: Sort expressions
4+Copyright: (c) Eitan Chatav, 2019
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+Sort expressions
9+-}
10+
111{-# LANGUAGE
212 DataKinds
313 , GADTs
@@ -19,8 +29,10 @@ import Squeal.PostgreSQL.Schema
1929-- of a `Squeal.PostgreSQL.Query.Query`. `Asc` or `Desc`
2030-- set the sort direction of a `NotNull` result
2131-- column to ascending or descending. Ascending order puts smaller values
22−-- first, where "smaller" is defined in terms of the `.<` operator. Similarly,
23−-- descending order is determined with the `.>` operator. `AscNullsFirst`,
32+-- first, where "smaller" is defined in terms of the
33+-- `Squeal.PostgreSQL.Expression.Comparison..<` operator. Similarly,
34+-- descending order is determined with the
35+-- `Squeal.PostgreSQL.Expression.Comparison..>` operator. `AscNullsFirst`,
2436-- `AscNullsLast`, `DescNullsFirst` and `DescNullsLast` options are used to
2537-- determine whether nulls appear before or after non-null values in the sort
2638-- ordering of a `Null` result column.
@@ -44,6 +56,16 @@ data SortExpression outer commons grp schemas params from where
4456 :: Expression outer commons grp schemas params from ('Null ty)
4557 -> SortExpression outer commons grp schemas params from
4658deriving instance Show (SortExpression outer commons grp schemas params from)
59+instance RenderSQL (SortExpression outer commons grp schemas params from) where
60+ renderSQL = \case
61+ Asc expression -> renderSQL expression <+> "ASC"
62+ Desc expression -> renderSQL expression <+> "DESC"
63+ AscNullsFirst expression -> renderSQL expression
64+ <+> "ASC NULLS FIRST"
65+ DescNullsFirst expression -> renderSQL expression
66+ <+> "DESC NULLS FIRST"
67+ AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
68+ DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
4769
4870{- |
4971The `orderBy` clause causes the result rows of a `Squeal.PostgreSQL.Query.TableExpression`
@@ -61,15 +83,3 @@ class OrderBy expr where
6183 :: [SortExpression outer commons grp schemas params from]
6284 -> expr outer commons grp schemas params from
6385 -> expr outer commons grp schemas params from
64−
65−-- | Render a `SortExpression`.
66−instance RenderSQL (SortExpression outer commons grp schemas params from) where
67− renderSQL = \case
68− Asc expression -> renderSQL expression <+> "ASC"
69− Desc expression -> renderSQL expression <+> "DESC"
70− AscNullsFirst expression -> renderSQL expression
71− <+> "ASC NULLS FIRST"
72− DescNullsFirst expression -> renderSQL expression
73− <+> "DESC NULLS FIRST"
74− AscNullsLast expression -> renderSQL expression <+> "ASC NULLS LAST"
75− DescNullsLast expression -> renderSQL expression <+> "DESC NULLS LAST"
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Text.hs+10
@@ -1,3 +1,13 @@
1+{-|
2+Module: Squeal.PostgreSQL.Expression.Text
3+Description: Text expressions
4+Copyright: (c) Eitan Chatav, 2019
5+Maintainer: eitan@morphism.tech
6+Stability: experimental
7+
8+String functions and operators
9+-}
10+
111{-# LANGUAGE
212 DataKinds
313 , OverloadedStrings
squeal-postgresql/src/Squeal/PostgreSQL/Expression/TextSearch.hs+1−1
@@ -5,7 +5,7 @@ Copyright: (c) Eitan Chatav, 2019
55Maintainer: eitan@morphism.tech
66Stability: experimental
77
8−Text Search Functions and Operators
8+Text search functions and operators
99-}
1010
1111{-# LANGUAGE
squeal-postgresql/src/Squeal/PostgreSQL/Expression/Time.hs+1−1
@@ -5,7 +5,7 @@ Copyright: (c) Eitan Chatav, 2019
55Maintainer: eitan@morphism.tech
66Stability: experimental
77
8−Date/Time Functions and Operators
8+Date/Time functions and operators
99-}
1010
1111{-# LANGUAGE