Skip to content
Snippets Groups Projects
Commit 7537c452 authored by Cam Saul's avatar Cam Saul
Browse files

test fix

parent 66c2ccff
No related branches found
No related tags found
No related merge requests found
......@@ -69,15 +69,15 @@
(defn- pre-add-implicit-fields
"Add an implicit `fields` clause to queries with `rows` aggregations."
[qp]
(fn [{{:keys [fields breakout], {source-table-id :id} :source-table, {ag-type :aggregation-type} :aggregation} :query, :as query}]
(fn [{{:keys [fields breakout source-table], {source-table-id :id} :source-table, {ag-type :aggregation-type} :aggregation} :query, :as query}]
(qp (if (or (not (= ag-type :rows)) breakout fields) query
(-> query
(assoc-in [:query :fields-is-implicit] true)
(assoc-in [:query :fields] (->> (sel :many [Field :name :base_type :special_type :table_id], :table_id source-table-id, :active true,
:preview_display true, :field_type [not= "sensitive"], (k/order :position :asc), (k/order :id :desc))
(map expand/rename-mb-field-keys)
;; TODO - we need to resolve the Tables for these newly added Fields (!)
(mapv expand/map->Field))))))))
(mapv expand/map->Field)))
(expand/resolve-tables source-table))))))
(defn- pre-add-implicit-breakout-order-by
......@@ -392,7 +392,6 @@
;;
;; Pre-processing then happens in order from bottom-to-top; i.e. POST-ANNOTATE gets to modify the results, then LIMIT, then CUMULATIVE-SUM, etc.
(defn- process-structured [driver query]
(let [driver-process-query (partial i/process-query driver)]
((<<- wrap-catch-exceptions
......
......@@ -124,13 +124,14 @@
[{database-id :database, :as expanded-query-dict}]
(assoc expanded-query-dict :database (sel :one :fields [Database :name :id :engine :details] :id database-id)))
(defn- resolve-tables
(defn resolve-tables
"Resolve the `Tables` in an EXPANDED-QUERY-DICT."
[{{source-table-id :source-table} :query, database-id :database, :as expanded-query-dict}]
;; TODO - this doesn't handle join tables yet
(let [table (sel :one :fields [Table :name :id] :id source-table-id)]
(->> (assoc-in expanded-query-dict [:query :source-table] table)
(walk/postwalk #(resolve-table % {(:id table) table})))))
([{{source-table-id :source-table} :query, :as expanded-query-dict}]
(resolve-tables expanded-query-dict (sel :one :fields [Table :name :id] :id source-table-id)))
([expanded-query-dict table]
{:pre [(map? table)]}
(->> (assoc-in expanded-query-dict [:query :source-table] table)
(walk/postwalk #(resolve-table % {(:id table) table})))))
;; ## -------------------- Public Interface --------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment