diff --git a/spago.yaml b/spago.yaml index 057e339..95ebeed 100644 --- a/spago.yaml +++ b/spago.yaml @@ -10,6 +10,7 @@ package: - effect - either - exceptions + - foldable-traversable - foreign - fork - maybe diff --git a/src/Data.Postgres.Query.Builder.purs b/src/Data.Postgres.Query.Builder.purs index 8edd317..afd5e54 100644 --- a/src/Data.Postgres.Query.Builder.purs +++ b/src/Data.Postgres.Query.Builder.purs @@ -2,8 +2,9 @@ module Data.Postgres.Query.Builder where import Prelude -import Control.Monad.State (StateT, modify, runStateT) +import Control.Monad.State (StateT, get, modify, runStateT) import Data.Array as Array +import Data.Foldable (any, elem) import Data.Set (Set) import Data.Set as Set import Data.Tuple.Nested (type (/\)) @@ -18,6 +19,11 @@ runBuilder = flip runStateT { params: [], refs: Set.empty } reference :: forall m. Monad m => String -> BuilderT m Unit reference k = void $ modify (\s@{ refs } -> s { refs = Set.insert k refs }) +isReferenced :: forall m. Monad m => Array String -> BuilderT m Boolean +isReferenced ts = do + { refs } <- get + pure $ any (flip elem ts) refs + param :: forall m a. Monad m => ToSQLValue a => a -> BuilderT m String param p = do