     (let [per-dataset-collection
           (group-by #(select-keys % [:dataset :collection]) features)]
       (doseq [[{:keys [dataset collection]} collection-features] per-dataset-collection]
-        (let [sql (gs-delete-sql dataset collection)
+        (let [sql (gs-delete-sql dataset (visualization dataset collection))
               ids (map #(vector (:id %)) collection-features)]
           (j/execute! db (cons sql ids) :multi? true :transaction? false))))))
 

(defn- conj!-when-not-nil [target src & srcs]
  (apply conj!-when target identity src srcs))

(defn- gs-dataset-exists? [db dataset]
  ;(println "dataset exists?")
  (pg/schema-exists? db dataset))

  (pg/create-schema db dataset))

(defn- gs-collection-exists? [db dataset collection]
  (let [table (visualization dataset collection)]
    (pg/table-exists? db dataset table)))

(defn- gs-create-collection [db dataset collection]
  "Create table with default fields"
  (let [table (visualization dataset collection)]
    (pg/create-table db dataset table
                [:gid "serial" :primary :key]
                [:_id "varchar(100)"]
                [:_geometry "geometry"])
    (pg/create-index db dataset table "_id")
    (pg/add-geo-constraints db dataset table :_geometry)
    (pg/populate-geometry-columns db dataset table)))

(defn- gs-collection-attributes [db dataset collection]
  ;(println "attributes")
