hasqlator-mysql 0.2.1 → 0.2.2
raw patch · 4 files changed
+188/−118 lines, 4 filesdep +non-emptydep ~mysql-haskellPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: non-empty
Dependency ranges changed: mysql-haskell
API changes (from Hackage documentation)
- Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.ToSql b => Database.MySQL.Hasqlator.InsertGeneric (GHC.Generics.K1 r Data.Text.Internal.Text ()) (GHC.Generics.K1 r b ())
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.ByteString.Internal.Type.ByteString
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.Scientific.Scientific
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.Text.Internal.Text
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.Time.Calendar.Days.Day
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.Time.Clock.Internal.DiffTime.DiffTime
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.Time.LocalTime.Internal.LocalTime.LocalTime
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Int.Int16
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Int.Int32
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Int.Int64
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Int.Int8
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Types.Double
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Types.Int
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Types.Word
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Word.Word16
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Word.Word32
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Word.Word64
- Database.MySQL.Hasqlator.Typed: instance Database.MySQL.Hasqlator.Typed.Castable GHC.Word.Word8
- Database.MySQL.Hasqlator.Typed: type Operator a b c = forall nullable. (Expression nullable a -> Expression nullable b -> Expression nullable c)
+ Database.MySQL.Hasqlator: cast :: Castable a => QueryBuilder -> QueryBuilder
+ Database.MySQL.Hasqlator: class Castable a
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.ByteString.Internal.Type.ByteString
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.Scientific.Scientific
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.Text.Internal.Text
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.Time.Calendar.Days.Day
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.Time.Clock.Internal.DiffTime.DiffTime
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.Time.LocalTime.Internal.LocalTime.LocalTime
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable Data.Time.LocalTime.Internal.TimeOfDay.TimeOfDay
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Int.Int16
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Int.Int32
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Int.Int64
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Int.Int8
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Types.Double
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Types.Int
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Types.Word
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Word.Word16
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Word.Word32
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Word.Word64
+ Database.MySQL.Hasqlator: instance Database.MySQL.Hasqlator.Castable GHC.Word.Word8
+ Database.MySQL.Hasqlator: rawValue :: QueryBuilder -> Selector MySQLValue
+ Database.MySQL.Hasqlator.Typed: type Operator a b c = forall (nullable :: Nullable). () => Expression nullable a -> Expression nullable b -> Expression nullable c
+ Database.MySQL.Hasqlator.Typed.Schema: [uniqueKeys] :: TableInfo -> [[Text]]
+ Database.MySQL.Hasqlator.Typed.Schema: instance GHC.Show.Show Database.MySQL.Hasqlator.Typed.Schema.UniqueKeys
- Database.MySQL.Hasqlator: type Getter s a = (a -> Const a a) -> s -> Const a s
+ Database.MySQL.Hasqlator: type Getter s a = a -> Const a a -> s -> Const a s
- Database.MySQL.Hasqlator.Typed: (:=) :: Field table database nullable a -> Expression nullable a -> Updator table database
+ Database.MySQL.Hasqlator.Typed: (:=) :: Field table database nullable a -> Expression nullable a -> Updator (table :: Symbol) database
- Database.MySQL.Hasqlator.Typed: (@@) :: Alias table database (joinType :: JoinType) -> Field table database fieldNull a -> Expression (JoinNullable joinType fieldNull) a
+ Database.MySQL.Hasqlator.Typed: (@@) :: forall (table :: Symbol) database (joinType :: JoinType) (fieldNull :: Nullable) a. Alias table database joinType -> Field table database fieldNull a -> Expression (JoinNullable joinType fieldNull) a
- Database.MySQL.Hasqlator.Typed: Alias :: (forall fieldNull a. Field table database fieldNull a -> Expression (JoinNullable joinType fieldNull) a) -> Alias table database (joinType :: JoinType)
+ Database.MySQL.Hasqlator.Typed: Alias :: (forall (fieldNull :: Nullable) a. () => Field table database fieldNull a -> Expression (JoinNullable joinType fieldNull) a) -> Alias (table :: Symbol) database (joinType :: JoinType)
- Database.MySQL.Hasqlator.Typed: All_ :: Expression nullable Bool -> All_ nullable
+ Database.MySQL.Hasqlator.Typed: All_ :: Expression nullable Bool -> All_ (nullable :: Nullable)
- Database.MySQL.Hasqlator.Typed: Any_ :: Expression nullable Bool -> Any_ nullable
+ Database.MySQL.Hasqlator.Typed: Any_ :: Expression nullable Bool -> Any_ (nullable :: Nullable)
- Database.MySQL.Hasqlator.Typed: [getAll_] :: All_ nullable -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: [getAll_] :: All_ (nullable :: Nullable) -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: [getAny_] :: Any_ nullable -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: [getAny_] :: Any_ (nullable :: Nullable) -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: [getTableAlias] :: Alias table database (joinType :: JoinType) -> forall fieldNull a. Field table database fieldNull a -> Expression (JoinNullable joinType fieldNull) a
+ Database.MySQL.Hasqlator.Typed: [getTableAlias] :: Alias (table :: Symbol) database (joinType :: JoinType) -> forall (fieldNull :: Nullable) a. () => Field table database fieldNull a -> Expression (JoinNullable joinType fieldNull) a
- Database.MySQL.Hasqlator.Typed: all_ :: Foldable f => (a -> Expression nullable Bool) -> f a -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: all_ :: forall f a (nullable :: Nullable). Foldable f => (a -> Expression nullable Bool) -> f a -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: and_ :: Foldable f => f (Expression nullable Bool) -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: and_ :: forall f (nullable :: Nullable). Foldable f => f (Expression nullable Bool) -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: any_ :: Foldable f => (a -> Expression nullable Bool) -> f a -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: any_ :: forall f a (nullable :: Nullable). Foldable f => (a -> Expression nullable Bool) -> f a -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: arg :: ToSql a => a -> Expression nullable a
+ Database.MySQL.Hasqlator.Typed: arg :: forall a (nullable :: Nullable). ToSql a => a -> Expression nullable a
- Database.MySQL.Hasqlator.Typed: cast :: Castable a => Expression nullable b -> Expression nullable a
+ Database.MySQL.Hasqlator.Typed: cast :: forall a b (nullable :: Nullable). Castable a => Expression nullable b -> Expression nullable a
- Database.MySQL.Hasqlator.Typed: data Updator table database
+ Database.MySQL.Hasqlator.Typed: data Updator (table :: Symbol) database
- Database.MySQL.Hasqlator.Typed: delete :: QueryClauses database (Alias table database 'InnerJoined) -> Command
+ Database.MySQL.Hasqlator.Typed: delete :: forall database (table :: Symbol). QueryClauses database (Alias table database 'InnerJoined) -> Command
- Database.MySQL.Hasqlator.Typed: exprInto :: Expression nullable a -> Field table database nullable a -> Into database table
+ Database.MySQL.Hasqlator.Typed: exprInto :: forall (nullable :: Nullable) a (table :: Symbol) database. Expression nullable a -> Field table database nullable a -> Into database table
- Database.MySQL.Hasqlator.Typed: false_ :: Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: false_ :: forall (nullable :: Nullable). Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: forShare :: [Table table database] -> WaitLock -> QueryClauses database ()
+ Database.MySQL.Hasqlator.Typed: forShare :: forall (table :: Symbol) database. [Table table database] -> WaitLock -> QueryClauses database ()
- Database.MySQL.Hasqlator.Typed: forUpdate :: [Table table database] -> WaitLock -> QueryClauses database ()
+ Database.MySQL.Hasqlator.Typed: forUpdate :: forall (table :: Symbol) database. [Table table database] -> WaitLock -> QueryClauses database ()
- Database.MySQL.Hasqlator.Typed: from :: Table table database -> QueryClauses database (Alias table database 'InnerJoined)
+ Database.MySQL.Hasqlator.Typed: from :: forall (table :: Symbol) database. Table table database -> QueryClauses database (Alias table database 'InnerJoined)
- Database.MySQL.Hasqlator.Typed: fun1 :: (QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b
+ Database.MySQL.Hasqlator.Typed: fun1 :: forall (nullable :: Nullable) a b. (QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b
- Database.MySQL.Hasqlator.Typed: fun2 :: (QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c
+ Database.MySQL.Hasqlator.Typed: fun2 :: forall (nullable :: Nullable) a b c. (QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c
- Database.MySQL.Hasqlator.Typed: fun3 :: (QueryBuilder -> QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c -> Expression nullable d
+ Database.MySQL.Hasqlator.Typed: fun3 :: forall (nullable :: Nullable) a b c d. (QueryBuilder -> QueryBuilder -> QueryBuilder -> QueryBuilder) -> Expression nullable a -> Expression nullable b -> Expression nullable c -> Expression nullable d
- Database.MySQL.Hasqlator.Typed: having :: Expression nullable Bool -> QueryClauses database ()
+ Database.MySQL.Hasqlator.Typed: having :: forall (nullable :: Nullable) database. Expression nullable Bool -> QueryClauses database ()
- Database.MySQL.Hasqlator.Typed: in_ :: Expression nullable a -> [Expression nullable a] -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: in_ :: forall (nullable :: Nullable) a. Expression nullable a -> [Expression nullable a] -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: innerJoin :: Table table database -> (Alias table database 'InnerJoined -> Expression nullable Bool) -> QueryClauses database (Alias table database 'InnerJoined)
+ Database.MySQL.Hasqlator.Typed: innerJoin :: forall (table :: Symbol) database (nullable :: Nullable). Table table database -> (Alias table database 'InnerJoined -> Expression nullable Bool) -> QueryClauses database (Alias table database 'InnerJoined)
- Database.MySQL.Hasqlator.Typed: insertData :: (Generic a, Generic b, InsertGeneric tbl db (Rep a ()) (Rep b ())) => a -> Insertor tbl db b
+ Database.MySQL.Hasqlator.Typed: insertData :: forall a b (tbl :: Symbol) db. (Generic a, Generic b, InsertGeneric tbl db (Rep a ()) (Rep b ())) => a -> Insertor tbl db b
- Database.MySQL.Hasqlator.Typed: insertOne :: ToSql a => Field table database 'NotNull fieldType -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: insertOne :: forall a (table :: Symbol) database fieldType. ToSql a => Field table database 'NotNull fieldType -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: insertSelect :: Table table database -> QueryClauses database [Into database table] -> Command
+ Database.MySQL.Hasqlator.Typed: insertSelect :: forall (table :: Symbol) database. Table table database -> QueryClauses database [Into database table] -> Command
- Database.MySQL.Hasqlator.Typed: insertUpdateValues :: Table table database -> Insertor table database a -> (Alias table database 'InnerJoined -> Alias table database 'InnerJoined -> [Updator table database]) -> [a] -> Command
+ Database.MySQL.Hasqlator.Typed: insertUpdateValues :: forall (table :: Symbol) database a. Table table database -> Insertor table database a -> (Alias table database 'InnerJoined -> Alias table database 'InnerJoined -> [Updator table database]) -> [a] -> Command
- Database.MySQL.Hasqlator.Typed: insertValues :: Table table database -> Insertor table database a -> [a] -> Command
+ Database.MySQL.Hasqlator.Typed: insertValues :: forall (table :: Symbol) database a. Table table database -> Insertor table database a -> [a] -> Command
- Database.MySQL.Hasqlator.Typed: insertWithout :: Field tables database nullable b -> Insertor table database a -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: insertWithout :: forall (tables :: Symbol) database (nullable :: Nullable) b (table :: Symbol) a. Field tables database nullable b -> Insertor table database a -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: into :: (a -> Expression nullable b) -> Field table database nullable b -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: into :: forall a (nullable :: Nullable) b (table :: Symbol) database. (a -> Expression nullable b) -> Field table database nullable b -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: isNull :: Expression nullable a -> Expression 'NotNull Bool
+ Database.MySQL.Hasqlator.Typed: isNull :: forall (nullable :: Nullable) a. Expression nullable a -> Expression 'NotNull Bool
- Database.MySQL.Hasqlator.Typed: joinSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'InnerJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> QueryClauses database outExprs
+ Database.MySQL.Hasqlator.Typed: joinSubQuery :: forall inExprs outExprs database (nullable :: Nullable). (Generic inExprs, Generic outExprs, SubQueryExpr 'InnerJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> QueryClauses database outExprs
- Database.MySQL.Hasqlator.Typed: leftJoin :: Table table database -> (Alias table database 'LeftJoined -> Expression nullable Bool) -> QueryClauses database (Alias table database 'LeftJoined)
+ Database.MySQL.Hasqlator.Typed: leftJoin :: forall (table :: Symbol) database (nullable :: Nullable). Table table database -> (Alias table database 'LeftJoined -> Expression nullable Bool) -> QueryClauses database (Alias table database 'LeftJoined)
- Database.MySQL.Hasqlator.Typed: leftJoinSubQuery :: (Generic inExprs, Generic outExprs, SubQueryExpr 'LeftJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> QueryClauses database outExprs
+ Database.MySQL.Hasqlator.Typed: leftJoinSubQuery :: forall inExprs outExprs database (nullable :: Nullable). (Generic inExprs, Generic outExprs, SubQueryExpr 'LeftJoined (Rep inExprs ()) (Rep outExprs ())) => Query database inExprs -> (outExprs -> Expression nullable Bool) -> QueryClauses database outExprs
- Database.MySQL.Hasqlator.Typed: lensInto :: ToSql b => Getter a b -> Field table database 'NotNull b -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: lensInto :: forall b a (table :: Symbol) database. ToSql b => Getter a b -> Field table database 'NotNull b -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: maybeLensInto :: ToSql b => Getter a (Maybe b) -> Field table database 'Nullable b -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: maybeLensInto :: forall b a (table :: Symbol) database. ToSql b => Getter a (Maybe b) -> Field table database 'Nullable b -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: maybeOpticInto :: (ToSql b, Is k A_Getter) => Optic' k is a (Maybe b) -> Field table database 'Nullable b -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: maybeOpticInto :: forall b k (is :: IxList) a (table :: Symbol) database. (ToSql b, Is k A_Getter) => Optic' k is a (Maybe b) -> Field table database 'Nullable b -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: newtype Alias table database (joinType :: JoinType)
+ Database.MySQL.Hasqlator.Typed: newtype Alias (table :: Symbol) database (joinType :: JoinType)
- Database.MySQL.Hasqlator.Typed: newtype All_ nullable
+ Database.MySQL.Hasqlator.Typed: newtype All_ (nullable :: Nullable)
- Database.MySQL.Hasqlator.Typed: newtype Any_ nullable
+ Database.MySQL.Hasqlator.Typed: newtype Any_ (nullable :: Nullable)
- Database.MySQL.Hasqlator.Typed: notIn_ :: Expression nullable a -> [Expression nullable a] -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: notIn_ :: forall (nullable :: Nullable) a. Expression nullable a -> [Expression nullable a] -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: nullable :: Expression nullable a -> Expression 'Nullable a
+ Database.MySQL.Hasqlator.Typed: nullable :: forall (nullable :: Nullable) a. Expression nullable a -> Expression 'Nullable a
- Database.MySQL.Hasqlator.Typed: opticInto :: (ToSql b, Is k A_Getter) => Optic' k is a b -> Field table database 'NotNull b -> Insertor table database a
+ Database.MySQL.Hasqlator.Typed: opticInto :: forall b k (is :: IxList) a (table :: Symbol) database. (ToSql b, Is k A_Getter) => Optic' k is a b -> Field table database 'NotNull b -> Insertor table database a
- Database.MySQL.Hasqlator.Typed: orNull :: Expression nullable a -> (Expression 'NotNull a -> Expression 'NotNull Bool) -> Expression 'NotNull Bool
+ Database.MySQL.Hasqlator.Typed: orNull :: forall (nullable :: Nullable) a. Expression nullable a -> (Expression 'NotNull a -> Expression 'NotNull Bool) -> Expression 'NotNull Bool
- Database.MySQL.Hasqlator.Typed: or_ :: Foldable f => f (Expression nullable Bool) -> Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: or_ :: forall f (nullable :: Nullable). Foldable f => f (Expression nullable Bool) -> Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: quotedFieldName :: Field table database nullable a -> Text
+ Database.MySQL.Hasqlator.Typed: quotedFieldName :: forall (table :: Symbol) database (nullable :: Nullable) a. Field table database nullable a -> Text
- Database.MySQL.Hasqlator.Typed: quotedTableName :: Table table database -> Text
+ Database.MySQL.Hasqlator.Typed: quotedTableName :: forall (table :: Symbol) database. Table table database -> Text
- Database.MySQL.Hasqlator.Typed: skipInsert :: Insertor tbl db a
+ Database.MySQL.Hasqlator.Typed: skipInsert :: forall (tbl :: Symbol) db a. Insertor tbl db a
- Database.MySQL.Hasqlator.Typed: someExpr :: Expression nullable a -> SomeExpression
+ Database.MySQL.Hasqlator.Typed: someExpr :: forall (nullable :: Nullable) a. Expression nullable a -> SomeExpression
- Database.MySQL.Hasqlator.Typed: subQueryExpr :: Query database (Expression nullable a) -> Expression nullable a
+ Database.MySQL.Hasqlator.Typed: subQueryExpr :: forall database (nullable :: Nullable) a. Query database (Expression nullable a) -> Expression nullable a
- Database.MySQL.Hasqlator.Typed: substr :: Expression nullable Text -> Expression nullable Int -> Expression nullable Int -> Expression nullable Text
+ Database.MySQL.Hasqlator.Typed: substr :: forall (nullable :: Nullable). Expression nullable Text -> Expression nullable Int -> Expression nullable Int -> Expression nullable Text
- Database.MySQL.Hasqlator.Typed: true_ :: Expression nullable Bool
+ Database.MySQL.Hasqlator.Typed: true_ :: forall (nullable :: Nullable). Expression nullable Bool
- Database.MySQL.Hasqlator.Typed: type Getter s a = (a -> Const a a) -> s -> Const a s
+ Database.MySQL.Hasqlator.Typed: type Getter s a = a -> Const a a -> s -> Const a s
- Database.MySQL.Hasqlator.Typed: unlessNull :: Expression nullable a -> (Expression 'NotNull a -> Expression 'NotNull Bool) -> Expression 'NotNull Bool
+ Database.MySQL.Hasqlator.Typed: unlessNull :: forall (nullable :: Nullable) a. Expression nullable a -> (Expression 'NotNull a -> Expression 'NotNull Bool) -> Expression 'NotNull Bool
- Database.MySQL.Hasqlator.Typed: unsafeCast :: Expression nullable a -> Expression nullable b
+ Database.MySQL.Hasqlator.Typed: unsafeCast :: forall (nullable :: Nullable) a b. Expression nullable a -> Expression nullable b
- Database.MySQL.Hasqlator.Typed: update :: Table table database -> (Alias table database 'InnerJoined -> QueryClauses database [Updator table database]) -> Command
+ Database.MySQL.Hasqlator.Typed: update :: forall (table :: Symbol) database. Table table database -> (Alias table database 'InnerJoined -> QueryClauses database [Updator table database]) -> Command
- Database.MySQL.Hasqlator.Typed: updateWithout :: Field table database nullable a -> [Updator table database] -> [Updator table database]
+ Database.MySQL.Hasqlator.Typed: updateWithout :: forall (table :: Symbol) database (nullable :: Nullable) a. Field table database nullable a -> [Updator table database] -> [Updator table database]
- Database.MySQL.Hasqlator.Typed.Schema: TableInfo :: Text -> Text -> [ColumnInfo] -> TableInfo
+ Database.MySQL.Hasqlator.Typed.Schema: TableInfo :: Text -> Text -> [ColumnInfo] -> [[Text]] -> TableInfo
Files
- hasqlator-mysql.cabal +3/−2
- src/Database/MySQL/Hasqlator.hs +121/−46
- src/Database/MySQL/Hasqlator/Typed.hs +6/−66
- src/Database/MySQL/Hasqlator/Typed/Schema.hs +58/−4
hasqlator-mysql.cabal view
@@ -1,5 +1,5 @@ Name: hasqlator-mysql-Version: 0.2.1+Version: 0.2.2 Synopsis: composable SQL generation Category: Database Copyright: Kristof Bastiaensen (2020)@@ -36,7 +36,7 @@ io-streams >= 1.5.2.1, megaparsec, mtl >= 2.1.3,- mysql-haskell,+ mysql-haskell >= 1.1.7, prettyprinter, scientific, text,@@ -44,6 +44,7 @@ template-haskell, aeson, pretty-simple,+ non-empty, optics-core >= 0.3 && < 0.5 hs-source-dirs: src
src/Database/MySQL/Hasqlator.hs view
@@ -8,6 +8,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE KindSignatures #-}+{-# LANGUAGE AllowAmbiguousTypes #-} {-| Module : Database.Hasqelator@@ -87,10 +88,12 @@ Similarly, you can use a lens to match the fields, using `lensInto` -> insertValues "authors" (_1 `lensInto` "name" <> _2 `lensInto` "birth_year")-> [("J.K. Rowling", 1965),-> ("Leo Tolstoy", 1828),-> ("Harper Lee", 1926)]+@+insertValues "authors" (_1 `lensInto` "name" <> _2 `lensInto` "birth_year")+ [("J.K. Rowling", 1965),+ ("Leo Tolstoy", 1828),+ ("Harper Lee", 1926)]+@ == Data types @@ -100,47 +103,50 @@ use skipInsert instead of the table name to skip fields you don't care about. -> data Borrower = Borrower-> { name :: Text-> , date_of_birth :: Day-> }->-> insertValues "borrowers" (insertData ("name", "date_of_birth"))-> [Borrower "John Doe" (fromJulian 1985 6 15),-> Borrower "Jane Smith" (fromJulian 1990 11 23),-> Borrower "Emily Johnson" (fromJulian 2000 8 30),-> Borrower "Michael Brown" (fromJulian 1982 2 10),-> Borrower "Sarah Davis" (fromJulian 1995 03 12)]+@+data Borrower = Borrower+ { name :: Text+ , date_of_birth :: Day+ } +insertValues "borrowers" (insertData ("name", "date_of_birth"))+ [Borrower "John Doe" (fromJulian 1985 6 15),+ Borrower "Jane Smith" (fromJulian 1990 11 23),+ Borrower "Emily Johnson" (fromJulian 2000 8 30),+ Borrower "Michael Brown" (fromJulian 1982 2 10),+ Borrower "Sarah Davis" (fromJulian 1995 03 12)]+@+ == Expressions Insert values can have arbitrary SQL queries, by using the `exprInto` function. Here I create a subquery, from the query which fetches author_id from an author name. -> data Book = Book-> { title :: String-> , author :: String-> , publishedYear :: Int-> , ageRating :: Int-> }->-> getBookAuthorId : Book -> Query Int-> getBookAuthorId Book{author=a} =-> select (sel "id") $-> from "authors" <>-> where_ ["name" =. arg a]-> -> insertValues (title `into` "title" <>-> (subQuery . getBookAuthorId `exprInto` "author_id") <>-> publishedYear `into` "published_year" <>-> ageRating `into` "age_rating")-> [ Book "1984" "George Orwell" 1903 16-> , Book "Brave New World" "Aldous Huxley" 1932 14,-> , Book "Harry Potter and the Philosopher\'s Stone" "J.K. Rowling" 1997 7-> , Book "War and Peace" "Leo Tolstoy" 1869 18-> ]+@+data Book = Book+ { title :: String+ , author :: String+ , publishedYear :: Int+ , ageRating :: Int+ } +getBookAuthorId : Book -> Query Int+getBookAuthorId Book{author=a} =+ select (sel "id") $+ from "authors" <>+ where_ ["name" =. arg a]++>>> insertValues (title `into` "title" <>+ (subQuery . getBookAuthorId `exprInto` "author_id") <>+ publishedYear `into` "published_year" <>+ ageRating `into` "age_rating")+ [ Book "1984" "George Orwell" 1903 16+ , Book "Brave New World" "Aldous Huxley" 1932 14,+ , Book "Harry Potter and the Philosopher\'s Stone" "J.K. Rowling" 1997 7+ , Book "War and Peace" "Leo Tolstoy" 1869 18+ ]+@ = Querying Queries are done using the `select` function. It takes a `Selector`,@@ -162,7 +168,7 @@ haskell datastructure. The query body can be composed using Monoid `mappend` (`<>`). For-example, here is a more complicated expression to get all books loaned+example, here is as more complicated expression to get all books loaned by a specific borrower: @@@ -236,13 +242,13 @@ localTimeSel, timeOfDaySel, diffTimeSel, daySel, byteStringSel, textSel, -- ** other selectors- rawValues, rawValues_,+ rawValues, rawValues_, rawValue, -- * Expressions subQuery, arg, fun, op, isNull, isNotNull, (>.), (<.), (>=.), (<=.), (+.), (-.), (*.), (/.), (=.), (++.), (/=.), (&&.), (||.), abs_, negate_, signum_, sum_,- rawSql, substr, in_, false_, true_, notIn_, values,+ rawSql, substr, in_, false_, true_, notIn_, values, Castable(..), -- * Insertion Insertor, insertValues, insertUpdateValues, insertSelect, insertData,@@ -295,8 +301,6 @@ import qualified System.IO.Streams as Streams import Control.Exception (throw, Exception) import qualified Data.Aeson as Aeson-import qualified Data.Aeson.Text as Aeson-import qualified Data.Text.Lazy as LazyText import Data.Maybe (mapMaybe) class FromSql a where@@ -743,9 +747,6 @@ InsertGeneric (M1 m1 m2 a ()) (M1 m3 m4 b ()) where insertDataGeneric = contramap unM1 . insertDataGeneric . unM1 -instance ToSql b => InsertGeneric (K1 r Text ()) (K1 r b ()) where- insertDataGeneric = contramap unK1 . insertOne . unK1- instance InsertGeneric (K1 r (Insertor a) ()) (K1 r a ()) where insertDataGeneric = contramap unK1 . unK1 @@ -958,12 +959,21 @@ -- | Read the columns directly as a `MySQLValue` type without conversion. rawValues :: [QueryBuilder] -> Selector [MySQLValue] rawValues cols = Selector (DList.fromList cols) $- state $ splitAt (length cols)+ state $ splitAt (length cols) -- | Ignore the content of the given columns rawValues_ :: [QueryBuilder] -> Selector () rawValues_ cols = () <$ rawValues cols +-- | Read a column as a `MySQLValue` type without conversion.+rawValue :: QueryBuilder -> Selector MySQLValue+rawValue col = Selector (DList.singleton col) $ do+ vals <- get+ case vals of+ [] -> throwError ResultSetCountError+ (v:rest) -> do put rest+ pure v+ forUpdate :: [QueryBuilder] -> WaitLock -> QueryClauses forUpdate qb wl = QueryClauses $ Endo $ \qc -> qc { _lockMode = Just $ ForUpdate qb wl }@@ -1026,6 +1036,71 @@ removeIt = map (`elem` toRemove) fields removeMaybe (True, _) = Nothing removeMaybe (False, x) = Just x++class Castable a where+ -- | Safe cast. This uses the SQL CAST function to convert safely+ -- from one type to another. Intended to be used with type applications+ -- (e.g. cast @Int expr)+ cast :: QueryBuilder -> QueryBuilder++castTo :: QueryBuilder -> QueryBuilder -> QueryBuilder+castTo tp x = fun "cast" [x `as` tp]++instance Castable StrictBS.ByteString where+ cast = castTo "BINARY"++instance Castable Text where+ cast = castTo "CHAR UNICODE"++instance Castable Day where+ cast = castTo "DATE"++instance Castable LocalTime where+ cast = castTo "DATETIME"++instance Castable Scientific where+ cast = castTo "DECIMAL"++instance Castable Double where+ cast = castTo "FLOAT[53]"++instance Castable Int where+ cast = castTo "SIGNED"++instance Castable Int8 where+ cast = castTo "SIGNED"++instance Castable Int16 where+ cast = castTo "SIGNED"++instance Castable Int32 where+ cast = castTo "SIGNED"++instance Castable Int64 where+ cast = castTo "SIGNED"++instance Castable TimeOfDay where+ cast = castTo "TIME"++instance Castable DiffTime where+ cast = castTo "TIME"++instance Castable Word where+ cast = castTo "UNSIGNED"++instance Castable Word8 where+ cast = castTo "UNSIGNED"++instance Castable Word16 where+ cast = castTo "UNSIGNED"++instance Castable Word32 where+ cast = castTo "UNSIGNED"++instance Castable Word64 where+ cast = castTo "UNSIGNED"++ instance FromSql Bool where fromSql (MySQLInt8U x) = pure $ x /= 0
src/Database/MySQL/Hasqlator/Typed.hs view
@@ -355,72 +355,12 @@ -> Expression 'NotNull Bool unlessNull e f = f (coerce e) -class Castable a where- -- | Safe cast. This uses the SQL CAST function to convert safely- -- from one type to another.- cast :: Expression nullable b- -> Expression nullable a--castTo :: H.QueryBuilder- -> Expression nullable b- -> Expression nullable a-castTo tp (Expression e) = Expression $ do- x <- e- pure $ H.fun "cast" [x `H.as` tp]--instance Castable StrictBS.ByteString where- cast = castTo "BINARY"--instance Castable Text where- cast = castTo "CHAR UNICODE"--instance Castable Day where- cast = castTo "DATE"--instance Castable LocalTime where- cast = castTo "DATETIME"--instance Castable Scientific where- cast = castTo "DECIMAL"--instance Castable Double where- cast = castTo "FLOAT[53]"--instance Castable Int where- cast = castTo "SIGNED"--instance Castable Int8 where- cast = castTo "SIGNED"--instance Castable Int16 where- cast = castTo "SIGNED"--instance Castable Int32 where- cast = castTo "SIGNED"--instance Castable Int64 where- cast = castTo "SIGNED"--instance Castable TimeOfDay where- cast = castTo "TIME"--instance Castable DiffTime where- cast = castTo "TIME"--instance Castable Word where- cast = castTo "UNSIGNED"--instance Castable Word8 where- cast = castTo "UNSIGNED"--instance Castable Word16 where- cast = castTo "UNSIGNED"--instance Castable Word32 where- cast = castTo "UNSIGNED"--instance Castable Word64 where- cast = castTo "UNSIGNED"+-- | Safe cast. This uses the SQL CAST function to convert safely+-- from one type to another.+cast :: forall a b nullable . H.Castable a+ => Expression nullable b+ -> Expression nullable a+cast (Expression e) = Expression $ H.cast @a <$> e -- | Cast the return type of an expression to any other type, without -- changing the query. Since this library adds static typing on top of
src/Database/MySQL/Hasqlator/Typed/Schema.hs view
@@ -5,6 +5,8 @@ {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TupleSections #-}+{-# LANGUAGE LambdaCase #-}+{- HLINT ignore STAN-0206 -} module Database.MySQL.Hasqlator.Typed.Schema (TableInfo(..), ColumnInfo(..), fetchTableInfo, Sign(..), ColumnType(..), pprTableInfo, Properties(..), defaultProperties, makeFields,@@ -31,6 +33,7 @@ import Data.Char import GHC.TypeLits(Symbol) import Text.Pretty.Simple+import Data.List.NonEmpty (groupWith, NonEmpty(..)) data Sign = Signed | Unsigned deriving Show@@ -75,8 +78,18 @@ { tableName :: Text , tableSchema :: Text , tableColumns :: [ColumnInfo]+ , uniqueKeys :: [[Text]] } deriving (Show) +data UniqueKeys = UniqueKeys+ { uniqueKeysTableSchema :: Text+ , uniqueKeysTableName :: Text+ , constraintName :: Text+ , uniqueKeysColumnName :: Text+ } deriving (Show)+++ argsP :: Parsec () Text a -> Parsec () Text [a] argsP p = between (single '(') (single ')') $ sepBy p (single ',') @@ -149,7 +162,34 @@ tableSchema_ <- textSel "TABLE_SCHEMA" pure $ TableInfo{ tableName = tableName_ , tableSchema = tableSchema_- , tableColumns = []}+ , tableColumns = []+ , uniqueKeys = []}++uniqueKeysQuery :: [Text] -> Query UniqueKeys+uniqueKeysQuery schemas =+ select keysSelector $+ from ("information_schema.TABLE_CONSTRAINTS" `as` "tc")+ <> leftJoin ["information_schema.KEY_COLUMN_USAGE" `as` "kcu"]+ [ "tc.CONSTRAINT_NAME" =. "kcu.CONSTRAINT_NAME"+ , "tc.TABLE_SCHEMA" =. "kcu.TABLE_SCHEMA"+ , "tc.TABLE_NAME" =. "kcu.TABLE_NAME"]+ <> where_ [ "tc.CONSTRAINT_TYPE" =. arg ("UNIQUE" :: Text)+ , "tc.TABLE_SCHEMA" `in_` map arg schemas]+ <> orderBy [Asc "tc.TABLE_SCHEMA",+ Asc "tc.TABLE_NAME",+ Asc "tc.CONSTRAINT_NAME",+ Asc "kcu.ORDINAL_POSITION"]+ where keysSelector = do+ tableSchema <- textSel "tc.TABLE_SCHEMA"+ tableName <- textSel "tc.TABLE_NAME"+ constraintName <- textSel "tc.CONSTRAINT_NAME"+ columnName <- textSel "kcu.COLUMN_NAME"+ pure $ UniqueKeys+ { uniqueKeysTableSchema = tableSchema+ , uniqueKeysTableName = tableName+ , constraintName = constraintName+ , uniqueKeysColumnName = columnName+ } columnsQuery :: [Text] -> Query ColumnInfo columnsQuery schemas =@@ -196,14 +236,27 @@ fetchTableInfo conn schemas = do tables <- executeQuery conn $ tableQuery schemas columns <- executeQuery conn $ columnsQuery schemas+ uniqueKeys <- executeQuery conn $ uniqueKeysQuery schemas let columnMap = Map.fromListWith (++) $ map (\ci -> ( (columnTableSchema ci, columnTableName ci) , [ci])) columns+ keysMap = Map.fromListWith (++) $+ map (\(uk1:|uks) ->+ ( (uniqueKeysTableSchema uk1,+ uniqueKeysTableName uk1)+ , [map uniqueKeysColumnName (uk1:uks)])) $+ groupWith (\uk ->+ (uniqueKeysTableSchema uk,+ uniqueKeysTableName uk,+ constraintName uk))+ uniqueKeys pure $ map (\tbl@TableInfo{tableName, tableSchema} -> tbl {tableColumns = Map.findWithDefault [] (tableSchema, tableName)- columnMap} )+ columnMap,+ uniqueKeys = Map.findWithDefault [] (tableSchema, tableName)+ keysMap} ) tables pprTableInfo :: LazyText.Text -> [TableInfo] -> LazyText.Text@@ -213,7 +266,7 @@ columnTHType :: Bool -> ColumnInfo -> Q Type columnTHType ignoreMaybe ColumnInfo{ columnType, columnNullable}- | columnNullable && not ignoreMaybe = [t| Maybe $(tp) |]+ | columnNullable && not ignoreMaybe = [t| Maybe $tp |] | otherwise = tp where tp = case columnType of TinyIntColumn _ -> [t| Int |]@@ -425,7 +478,8 @@ |] , valD (varP insertorName) (normalB $ foldr1 (\x y -> [| $(x) <> $(y) |]) $- map insertorField $ filter (not . autoIncrement) $ tableColumns ti)+ map insertorField $ filter (not . autoIncrement) $+ tableColumns ti) [] ] where