Fix embedded column conflicts table name (#996)

This commit is contained in:
grotsev
2017-10-05 21:03:27 -05:00
committed by Joe Nelson
parent 7bf384d0f8
commit 8f49f731d0
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -245,7 +245,7 @@ requestToQuery schema isParent (DbRead (Node (Select colSelects tbls logicForest
getQueryParts (Node n@(_, (name, Just Relation{relType=Child,relTable=Table{tableName=table}}, alias, _)) forst) (j,s) = (j,sel:s)
where
sel = "COALESCE(("
<> "SELECT array_to_json(array_agg(row_to_json("<>pgFmtIdent table<>"))) "
<> "SELECT array_to_json(array_agg(row_to_json("<>pgFmtIdent table<>".*))) "
<> "FROM (" <> subquery <> ") " <> pgFmtIdent table
<> "), '[]') AS " <> pgFmtIdent (fromMaybe name alias)
where subquery = requestToQuery schema False (DbRead (Node n forst))
@@ -262,7 +262,7 @@ requestToQuery schema isParent (DbRead (Node (Select colSelects tbls logicForest
getQueryParts (Node n@(_, (name, Just Relation{relType=Many,relTable=Table{tableName=table}}, alias, _)) forst) (j,s) = (j,sel:s)
where
sel = "COALESCE (("
<> "SELECT array_to_json(array_agg(row_to_json("<>pgFmtIdent table<>"))) "
<> "SELECT array_to_json(array_agg(row_to_json("<>pgFmtIdent table<>".*))) "
<> "FROM (" <> subquery <> ") " <> pgFmtIdent table
<> "), '[]') AS " <> pgFmtIdent (fromMaybe name alias)
where subquery = requestToQuery schema False (DbRead (Node n forst))