Support for extracting fields from json columns

This commit is contained in:
Ruslan Talpa
2015-09-02 12:41:02 +03:00
parent b9fec2ce41
commit 40d4fb0d75
+5 -1
View File
@@ -141,7 +141,11 @@ selectT table params =
cols = filter ((>0) . T.length) $ map T.strip $ T.split (==',') $ cs columnsParam
selectTerm :: QualifiedIdentifier -> T.Text -> PStmt
selectTerm table col = B.Stmt (pgFmtJsonbPath table (cs col)) empty True
selectTerm table col = B.Stmt (pgFmtJsonbPath table (cs col) <> asT jsonbPath) empty True
where
jsonbPath = parseJsonbPath $ cs col
asT (Just (DoubleArrow _ (KeyIdentifier key))) = " AS " <> pgFmtIdent key
asT _ = ""
returningStarT :: StatementT
returningStarT s = s { B.stmtTemplate = B.stmtTemplate s <> " RETURNING *" }