packages feed

hasbolt-extras 0.0.0.11 → 0.0.0.12

raw patch · 7 files changed

+30/−9 lines, 7 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

- Database.Bolt.Extras.Graph: instance (GHC.Show.Show b, GHC.Show.Show a, GHC.Show.Show n) => GHC.Show.Show (Database.Bolt.Extras.Graph.Graph n a b)
+ Database.Bolt.Extras.DSL: Remove :: [Text] -> next -> Expr next
+ Database.Bolt.Extras.DSL: removeF :: [Text] -> Free Expr ()
+ Database.Bolt.Extras.Graph: instance (GHC.Show.Show n, GHC.Show.Show a, GHC.Show.Show b) => GHC.Show.Show (Database.Bolt.Extras.Graph.Graph n a b)
- Database.Bolt.Extras.Template: data Node :: *
+ Database.Bolt.Extras.Template: data Node
- Database.Bolt.Extras.Template: data Relationship :: *
+ Database.Bolt.Extras.Template: data Relationship
- Database.Bolt.Extras.Template: data URelationship :: *
+ Database.Bolt.Extras.Template: data URelationship
- Database.Bolt.Extras.Template: data Value :: *
+ Database.Bolt.Extras.Template: data Value

Files

CHANGELOG.md view
@@ -6,6 +6,12 @@  ## [Unreleased] +## [0.0.0.12] - 2018-10-15+### Added+- `REMOVE` query.+### Fixed+- Escaping special characters in text fields.+ ## [0.0.0.11] - 2018-06-19 ### Changed - Cabal fix.
hasbolt-extras.cabal view
@@ -1,5 +1,5 @@ name:           hasbolt-extras-version:        0.0.0.11+version:        0.0.0.12 synopsis:       Extras for hasbolt library description:    Extras for hasbolt library homepage:       https://github.com/biocad/hasbolt-extras#readme
src/Database/Bolt/Extras/DSL/Internal/Executer.hs view
@@ -28,6 +28,7 @@ execute (Set t n)           = executeHelperT "SET " t n execute (Delete t n)        = executeHelperT "DELETE " t n execute (DetachDelete t n)  = executeHelperT "DETACH DELETE " t n+execute (Remove t n)        = executeHelperT "REMOVE " t n execute (Return t n)        = executeHelperT "RETURN " t n execute (Text t n)          = tell [t] >> pure n 
src/Database/Bolt/Extras/DSL/Internal/Language.hs view
@@ -8,6 +8,7 @@   , setF   , deleteF   , detachDeleteF+  , removeF   , returnF   , textF   ) where@@ -56,6 +57,11 @@ -- detachDeleteF :: [Text] -> Free Expr () detachDeleteF txts = liftF (DetachDelete txts ())++-- | Prepare 'REMOVE' query+--+removeF :: [Text] -> Free Expr ()+removeF txts = liftF (Remove txts ())  -- | Prepare 'RETURN' query --
src/Database/Bolt/Extras/DSL/Internal/Types.hs view
@@ -103,6 +103,7 @@                | Set [Text] next              -- ^ SET query                | Delete [Text] next           -- ^ DELETE query                | DetachDelete [Text] next     -- ^ DETACH DELETE query+               | Remove [Text] next           -- ^ REMOVE query                | Return [Text] next           -- ^ RETURN query                | Text Text next               -- ^ free text query   deriving (Show, Eq, Functor)
src/Database/Bolt/Extras/Query/Cypher.hs view
@@ -15,8 +15,10 @@ -- This file contains some converation rules from 'Database.Bolt' types to `Cypher`. ------------------------------------------------------------------------------------------------- +import           Data.Monoid                   ((<>)) import           Data.Text                     as T (Text, concat, cons,-                                                     intercalate, pack, toUpper)+                                                     intercalate, pack, replace,+                                                     toUpper) import           Database.Bolt                 (Value (..)) import           Database.Bolt.Extras.Template (Label, Property) import           Database.Bolt.Extras.Utils    (currentLoc)@@ -34,10 +36,13 @@   toCypher (B bool)   = toUpper . pack . show $ bool   toCypher (I int)    = pack . show $ int   toCypher (F double) = pack . show $ double-  toCypher (T t)      = [text|"$t"|]+  toCypher (T t)      = "\"" <> escapeSpecSymbols t <> "\""   toCypher (L values) = let cvalues = T.intercalate "," $ map toCypher values                         in [text|[$cvalues]|]   toCypher _          = error $ $currentLoc ++ "unacceptable Value type"++escapeSpecSymbols :: Text -> Text+escapeSpecSymbols = replace "\"" "\\\"" . replace "\\" "\\\\"  -- | Label with @name@ are formatted into @:name@ --
src/Database/Bolt/Extras/Query/Set.hs view
@@ -7,10 +7,12 @@   ) where  import           Control.Monad.IO.Class              (MonadIO)-import           Data.Text                           (Text, append, intercalate)+import           Data.Monoid                         ((<>))+import           Data.Text                           (Text, intercalate) import           Database.Bolt                       (BoltActionT,-                                                      RecordValue (..), at,-                                                      exact, query, Value (..))+                                                      RecordValue (..),+                                                      Value (..), at, exact,+                                                      query) import           Database.Bolt.Extras.Persisted      (BoltId, fromInt) import           Database.Bolt.Extras.Query.Cypher   (ToCypher (..)) import           Database.Bolt.Extras.Query.Get      (NodeGetter, condIdAsText,@@ -26,7 +28,7 @@     let nodeGetterT = nodeAsText (varQ, nodeGetter)     let condId      = condIdAsText (varQ, nodeGetter) -    let newProperties = intercalate "," $ fmap formPropertySet $ filter ((/= N ()) . snd) props+    let newProperties = intercalate "," $ formPropertySet <$> filter ((/= N ()) . snd) props      let getQuery = [text|MATCH $nodeGetterT                          WHERE $condId@@ -41,7 +43,7 @@     varQ = "n"      formPropertyName :: Text -> Text-    formPropertyName n = varQ `append` "." `append` n+    formPropertyName n = varQ <> "." <> n      formPropertySet :: Property -> Text-    formPropertySet (name, prop) = formPropertyName name `append` "=" `append` toCypher prop+    formPropertySet (name, prop) = formPropertyName name <> "=" <> toCypher prop