Add support for getting json by array index

* Also support json negative array index
This commit is contained in:
steve-chavez
2018-06-19 11:17:59 -05:00
committed by Steve Chávez
parent 2513c00039
commit 30dfadec7b
11 changed files with 172 additions and 21 deletions
+6 -1
View File
@@ -238,7 +238,12 @@ instance Show LogicOperator where
data LogicTree = Expr Bool LogicOperator [LogicTree] | Stmnt Filter deriving (Show, Eq)
type FieldName = Text
type JsonPath = [Text]
type JsonPath = [JsonPathOp]
{-|
Json path operands as specified in https://www.postgresql.org/docs/9.5/static/functions-json.html
the array index is Text because we reuse our escaping functons and let pg do the casting with '1'::int
-}
data JsonPathOp = JKey{jpOp :: Text} | JIdx{jpOp :: Text} deriving (Show, Eq)
type Field = (FieldName, JsonPath)
type Alias = Text
type Cast = Text