diff options
Diffstat (limited to 'src/Store/Query')
-rw-r--r-- | src/Store/Query/Parser.hs | 4 | ||||
-rw-r--r-- | src/Store/Query/Printer.hs | 4 | ||||
-rw-r--r-- | src/Store/Query/Type.hs | 2 |
3 files changed, 6 insertions, 4 deletions
diff --git a/src/Store/Query/Parser.hs b/src/Store/Query/Parser.hs index e16c926..99ddc79 100644 --- a/src/Store/Query/Parser.hs +++ b/src/Store/Query/Parser.hs @@ -114,9 +114,9 @@ instance IsString Query where ] comparison = do - a <- field + a <- P.choice [Left <$> value, Right <$> field] eq - b <- field + b <- P.choice [Left <$> value, Right <$> field] pure $ Eq a b fieldSelector = diff --git a/src/Store/Query/Printer.hs b/src/Store/Query/Printer.hs index 26f4e8b..cff543f 100644 --- a/src/Store/Query/Printer.hs +++ b/src/Store/Query/Printer.hs @@ -102,7 +102,9 @@ showWhereClauseWith wrap (Just (Or ws)) = Just (wrap (intercalate "OR" (mapMaybe showWhereClauseWith _ (Just (Where p)) = Just (showComparison p) showComparison :: Comparison -> String -showComparison (Eq a b) = intercalate " " [showField a, "==", showField b] +showComparison (Eq a b) = intercalate " " [showArg a, "==", showArg b] + where + showArg = either showValue showField showValues :: [J.Value] -> Maybe String showValues [] = Nothing diff --git a/src/Store/Query/Type.hs b/src/Store/Query/Type.hs index 7065267..912d020 100644 --- a/src/Store/Query/Type.hs +++ b/src/Store/Query/Type.hs @@ -62,5 +62,5 @@ data WhereClause deriving (Show) data Comparison - = Eq Field Field + = Eq (Either J.Value Field) (Either J.Value Field) deriving (Show) |