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

did that fix it!

parent 4746cea1
Branches
Tags
No related merge requests found
......@@ -210,12 +210,3 @@
query-execution)
;; first time saving execution, so insert it
(mapply ins QueryExecution query-execution)))
(defn x [db-id]
(let [db (sel :one Database :id db-id)
driver (database-id->driver db-id)
connection-details ((:database->connection-details driver) db)
connection-spec ((:connection-details->connection-spec driver) connection-details)]
(clojure.pprint/pprint connection-details)
(clojure.pprint/pprint connection-spec)
(i/active-table-names driver db)))
......@@ -119,6 +119,7 @@
(defn update-table-row-count!
"Update the row count of TABLE if it has changed."
[table]
{:pre [(integer? (:id table))]}
(let [table-row-count (queries/table-row-count table)]
(when-not (= (:rows table) table-row-count)
(upd Table (:id table) :rows table-row-count))))
......@@ -198,11 +199,14 @@
(when-let [dest-table-id (table-name->id dest-table-name)]
(when-let [dest-column-id (sel :one :id Field :table_id dest-table-id :name dest-column-name)]
(log/info (format "Marking foreign key '%s.%s' -> '%s.%s'." (:name table) fk-column-name dest-table-name dest-column-name))
(log/info "<1>")
(ins ForeignKey
:origin_id fk-column-id
:destination_id dest-column-id
:relationship (determine-fk-type {:id fk-column-id, :table (delay table)})) ; fake a Field instance
(upd Field fk-column-id :special_type :fk))))))))))
(log/info "<2>")
(upd Field fk-column-id :special_type :fk)
(log/info "<3>"))))))))))
;; ### 4) sync-table-fields-metadata!
......
......@@ -6,28 +6,35 @@
(defn- qp-query [table query-dict]
(binding [context/*table* table
context/*database* @(:db table)]
(driver/process-query {:database (:db_id table)
:type "query"
:query (assoc query-dict
:source_table (:id table))})))
(-> (driver/process-query {:database (:db_id table)
:type "query"
:query (assoc query-dict
:source_table (:id table))})
:data
:rows)))
(defn table-row-count
"Fetch the row count of TABLE via the query processor."
[table]
{:post [(integer? %)]}
{:pre [(map? table)]
:post [(integer? %)]}
(-> (qp-query table {:aggregation ["count"]})
first first))
(defn field-count
"Return the count of FIELD via the query processor."
[field]
{:post [(integer? %)]}
{:pre [(delay? (:table field))
(integer? (:id field))]
:post [(integer? %)]}
(-> (qp-query @(:table field) {:aggregation ["count" (:id field)]})
first first))
(defn field-distinct-count
"Return the distinct count of FIELD via the query processor."
[field]
{:post [(integer? %)]}
{:pre [(delay? (:table field))
(integer? (:id field))]
:post [(integer? %)]}
(-> (qp-query @(:table field) {:aggregation ["distinct" (:id field)]})
first first))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment