Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LiteralSQL instances to ByteStrings #80

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions relational-query/src/Database/Relational/Pure.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
module Database.Relational.Pure () where

import Control.Applicative (pure)
import qualified Data.ByteString.Char8 as BC
import qualified Data.ByteString.Lazy.Char8 as BCL
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Word (Word8, Word16, Word32, Word64, Word)
import Data.Text (Text)
Expand Down Expand Up @@ -130,6 +132,12 @@ instance LiteralSQL TimeOfDay where
instance LiteralSQL LocalTime where
showLiteral' = pure . Lit.timestamp TIMESTAMP "%Y-%m-%d %H:%M:%S"

instance LiteralSQL BC.ByteString where
showLiteral' = pure . Lit.stringExpr . BC.unpack

instance LiteralSQL BCL.ByteString where
showLiteral' = pure . Lit.stringExpr . BCL.unpack

showMaybeTerms :: LiteralSQL a => PersistableRecordWidth a -> Maybe a -> DList StringSQL
showMaybeTerms wa = d where
d (Just a) = showLiteral' a
Expand Down