git.iko.soy/typeable/postgresql-simple
on master help sign in
Add instance IsString QualifiedIdentifier
f0bfbb9Leon P Smith
src/Database/PostgreSQL/Simple/Types.hs+8
@@ -139,6 +139,14 @@ data QualifiedIdentifier = QualifiedIdentifier (Maybe ByteString) ByteString
139instance Hashable QualifiedIdentifier where
139instance Hashable QualifiedIdentifier where
140 hashWithSalt i (QualifiedIdentifier q t) = hashWithSalt i (q, t)
140 hashWithSalt i (QualifiedIdentifier q t) = hashWithSalt i (q, t)
141
141
142+instance IsString QualifiedIdentifier where
143+ fromString str = let (x,y) = B.break (== 46)
144+ . toByteString
145+ . Utf8.fromString $ str
146+ in if B.null y
147+ then QualifiedIdentifier Nothing x
148+ else QualifiedIdentifier (Just x) (B.tail y)
149+
142-- | Wrap a list for use as a PostgreSQL array.
150-- | Wrap a list for use as a PostgreSQL array.
143newtype PGArray a = PGArray {fromPGArray :: [a]}
151newtype PGArray a = PGArray {fromPGArray :: [a]}
144 deriving (Eq, Ord, Read, Show, Typeable, Functor)
152 deriving (Eq, Ord, Read, Show, Typeable, Functor)