changed identation to 2 spaces to match the rest of the project
This commit is contained in:
@@ -145,7 +145,8 @@ dbRequestToQuery (Node (Select mainTable colSelects tbls conditions _ ord) fores
|
|||||||
--posible relations are Child Parent Many
|
--posible relations are Child Parent Many
|
||||||
getQueryParts :: Tree Query -> ([Text], [Text]) -> ([Text], [Text])
|
getQueryParts :: Tree Query -> ([Text], [Text]) -> ([Text], [Text])
|
||||||
getQueryParts (Node q@(Select{qMainTable=table, qRelation=(Just (Relation {relType="child"}))}) forst) (w,s) = (w,sel:s)
|
getQueryParts (Node q@(Select{qMainTable=table, qRelation=(Just (Relation {relType="child"}))}) forst) (w,s) = (w,sel:s)
|
||||||
where name = tableName table
|
where
|
||||||
|
name = tableName table
|
||||||
sel = "("
|
sel = "("
|
||||||
<> "SELECT array_to_json(array_agg(row_to_json("<>name<>"))) "
|
<> "SELECT array_to_json(array_agg(row_to_json("<>name<>"))) "
|
||||||
<> "FROM (" <> subquery <> ") " <> name
|
<> "FROM (" <> subquery <> ") " <> name
|
||||||
@@ -153,7 +154,8 @@ dbRequestToQuery (Node (Select mainTable colSelects tbls conditions _ ord) fores
|
|||||||
where (B.Stmt subquery _ _) = dbRequestToQuery (Node q forst)
|
where (B.Stmt subquery _ _) = dbRequestToQuery (Node q forst)
|
||||||
|
|
||||||
getQueryParts (Node q@(Select{qMainTable=table, qRelation=(Just (Relation{relType="parent"}))}) forst) (w,s) = (wit:w,sel:s)
|
getQueryParts (Node q@(Select{qMainTable=table, qRelation=(Just (Relation{relType="parent"}))}) forst) (w,s) = (wit:w,sel:s)
|
||||||
where name = tableName table
|
where
|
||||||
|
name = tableName table
|
||||||
sel = "row_to_json(" <> name <> ".*) AS "<>name --TODO must be singular
|
sel = "row_to_json(" <> name <> ".*) AS "<>name --TODO must be singular
|
||||||
wit = name <> " AS ( " <> subquery <> " )"
|
wit = name <> " AS ( " <> subquery <> " )"
|
||||||
where (B.Stmt subquery _ _) = dbRequestToQuery (Node q forst)
|
where (B.Stmt subquery _ _) = dbRequestToQuery (Node q forst)
|
||||||
|
|||||||
Reference in New Issue
Block a user