packages feed

opaleye 0.3.1 → 0.3.1.1

raw patch · 9 files changed

+48/−12 lines, 9 filesdep +base16-bytestringdep +bytestringdep −old-localedep ~timePVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

Dependencies added: base16-bytestring, bytestring

Dependencies removed: old-locale

Dependency ranges changed: time

API changes (from Hackage documentation)

+ Opaleye.Internal.HaskellDB.PrimQuery: ByteStringLit :: ByteString -> Literal
+ Opaleye.Internal.HaskellDB.Sql.Default: binQuote :: ByteString -> String
+ Opaleye.Internal.RunQuery: instance QueryRunnerColumnDefault PGBytea ByteString
+ Opaleye.PGTypes: data PGBytea
+ Opaleye.PGTypes: pgLazyByteString :: ByteString -> Column PGBytea
+ Opaleye.PGTypes: pgStrictByteString :: ByteString -> Column PGBytea

Files

CHANGELOG.md view
@@ -1,11 +1,14 @@+## 0.3.1.1++* Bump time to >= 1.5+ ## 0.3.1  * SQL code generator escapes column names, so table column names can   be the same as SQL keywords. * Add `like` operator * Add the types `PGCitext`, `PGArray`, `PGBytea`-* -	+ ## 0.3  * Replace `Default QueryRunner` with a new class `DefaultQueryRunnerColumn`, migrate with `s/Default QueryRunner/DefaultQueryRunnerColumn` and `s/def/queryRunnerColumnDefault/`
TODO.md view
@@ -1,6 +1,11 @@ # Low priority -* General type families for improving instance resolution (product-profunctors)+* General type families for improving instance resolution+  (product-profunctors).  (Currently there are three places in Opaleye+  where instance resolution needs to happen: `runQuery`,+  `runInsertReturning` and `leftJoin`.  As it happens it seems+  difficult to make any of these benefit from a general type family+  approach.)  ## Good starter projects for someone wanting to contribute to Opaleye 
opaleye.cabal view
@@ -1,5 +1,5 @@ name:            opaleye-version:         0.3.1+version:         0.3.1.1 synopsis:        An SQL-generating DSL targeting PostgreSQL description:     An SQL-generating DSL targeting PostgreSQL.  Allows                  Postgres queries to be written within Haskell in a@@ -26,17 +26,18 @@       -- Internal.RunQuery is merged upstream       attoparsec          >= 0.10.3  && < 0.13     , base                >= 4       && < 5+    , base16-bytestring   >= 0.1.1.6 && < 0.2     , case-insensitive    >= 1.2     && < 1.3-    , contravariant       >= 0.4.4   && < 1.3-    , old-locale          >= 1.0     && < 1.1+    , bytestring          >= 0.10    && < 0.11+    , contravariant       >= 0.4.4   && < 1.4     , postgresql-simple   >= 0.4.8.0 && < 0.5     , pretty              >= 1.1.1.0 && < 1.2     , product-profunctors >= 0.5     && < 0.7-    , profunctors         >= 4.0     && < 4.4+    , profunctors         >= 4.0     && < 4.5     , semigroups          >= 0.13    && < 0.17     , text                >= 0.11    && < 1.3     , transformers        >= 0.3     && < 0.5-    , time                >= 1.4     && < 1.5+    , time                >= 1.5     && < 1.6     , uuid                >= 1.3     && < 1.4   exposed-modules: Opaleye,                    Opaleye.Aggregate,
src/Opaleye/Column.hs view
@@ -11,7 +11,7 @@  -- | A NULL of any type null :: Column (Nullable a)-null = unsafeCoerce (C.Column (HPQ.ConstExpr HPQ.NullLit))+null = C.Column (HPQ.ConstExpr HPQ.NullLit)  isNull :: Column (Nullable a) -> Column T.PGBool isNull = C.unOp HPQ.OpIsNull
src/Opaleye/Internal/HaskellDB/PrimQuery.hs view
@@ -5,6 +5,7 @@ module Opaleye.Internal.HaskellDB.PrimQuery where  import qualified Opaleye.Internal.Tag as T+import Data.ByteString (ByteString)  type TableName  = String type Attribute  = String@@ -31,6 +32,7 @@ 	     | DefaultLit            -- ^ represents a default value 	     | BoolLit Bool 	     | StringLit String+             | ByteStringLit ByteString 	     | IntegerLit Integer 	     | DoubleLit Double 	     | OtherLit String       -- ^ used for hacking in custom SQL
src/Opaleye/Internal/HaskellDB/Sql/Default.hs view
@@ -8,6 +8,9 @@ import Opaleye.Internal.HaskellDB.Sql import Opaleye.Internal.HaskellDB.Sql.Generate import Opaleye.Internal.Tag (tagWith)+import Data.ByteString (ByteString)+import qualified Data.ByteString.Char8 as BS8+import qualified Data.ByteString.Base16 as Base16  mkSqlGenerator :: SqlGenerator -> SqlGenerator mkSqlGenerator gen = SqlGenerator @@ -169,6 +172,8 @@       DefaultLit    -> "DEFAULT"       BoolLit True  -> "TRUE"       BoolLit False -> "FALSE"+      ByteStringLit s+                    -> binQuote s       StringLit s   -> quote s       IntegerLit i  -> show i       DoubleLit d   -> show d@@ -195,3 +200,8 @@ escape '\t' = "\\t" escape '\\' = "\\\\" escape c = [c]+++-- | Quote binary literals using Postgresql's hex format.+binQuote :: ByteString -> String+binQuote s = "E'\\\\x" ++ BS8.unpack (Base16.encode s) ++ "'"
src/Opaleye/Internal/RunQuery.hs view
@@ -25,6 +25,8 @@ import qualified Data.CaseInsensitive as CI import qualified Data.Text as ST import qualified Data.Text.Lazy as LT+import qualified Data.ByteString as SBS+import qualified Data.ByteString.Lazy as LBS import qualified Data.Time as Time import           Data.UUID (UUID) import           GHC.Int (Int64)@@ -106,6 +108,12 @@   queryRunnerColumnDefault = fieldQueryRunnerColumn  instance QueryRunnerColumnDefault T.PGUuid UUID where+  queryRunnerColumnDefault = fieldQueryRunnerColumn++instance QueryRunnerColumnDefault T.PGBytea SBS.ByteString where+  queryRunnerColumnDefault = fieldQueryRunnerColumn++instance QueryRunnerColumnDefault T.PGBytea LBS.ByteString where   queryRunnerColumnDefault = fieldQueryRunnerColumn  instance QueryRunnerColumnDefault T.PGText ST.Text where
src/Opaleye/Operators.hs view
@@ -43,7 +43,6 @@ (.>=) :: Column a -> Column a -> Column T.PGBool (.>=) = C.binOp HPQ.OpGtEq --- For import order reasons we can't make the return type PGBool case_ :: [(Column T.PGBool, Column a)] -> Column a -> Column a case_ = unsafeCase_ 
src/Opaleye/PGTypes.hs view
@@ -10,9 +10,10 @@ import qualified Data.CaseInsensitive as CI import qualified Data.Text as SText import qualified Data.Text.Lazy as LText+import qualified Data.ByteString as SByteString+import qualified Data.ByteString.Lazy as LByteString import qualified Data.Time as Time import qualified Data.UUID as UUID-import qualified System.Locale as SL  import           Data.Int (Int64) @@ -31,6 +32,7 @@ data PGUuid data PGCitext data PGArray a+data PGBytea  instance C.PGNum PGFloat8 where   pgFromInteger = pgDouble . fromInteger@@ -50,6 +52,12 @@ pgString :: String -> Column PGText pgString = literalColumn . HPQ.StringLit +pgLazyByteString :: LByteString.ByteString -> Column PGBytea+pgLazyByteString = literalColumn . HPQ.ByteStringLit . LByteString.toStrict++pgStrictByteString :: SByteString.ByteString -> Column PGBytea+pgStrictByteString = literalColumn . HPQ.ByteStringLit+ pgStrictText :: SText.Text -> Column PGText pgStrictText = literalColumn . HPQ.StringLit . SText.unpack @@ -78,7 +86,7 @@                                      . HPQ.ConstExpr                                      . HPQ.OtherLit                                      . format-  where format = Time.formatTime SL.defaultTimeLocale formatString+  where format = Time.formatTime Time.defaultTimeLocale formatString  pgDay :: Time.Day -> Column PGDate pgDay = unsafePgFormatTime "date" "'%F'"