Skip to content

Commit

Permalink
Adding http support
Browse files Browse the repository at this point in the history
  • Loading branch information
Markenson committed Jan 16, 2021
1 parent 19f9e8c commit a732f32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 2 additions & 2 deletions csv/project.clj
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
(defproject metabase/csv-driver "1.0.0-SNAPSHOT"
(defproject metabase/csv-driver "1.0.1-SNAPSHOT"
:min-lein-version "2.5.0"

:repositories {"sonartype snapshots" "https://oss.sonatype.org/content/repositories/snapshots"}
:dependencies
[[br.com.markenson/csvjdbc "1.0.10-metabase-SNAPSHOT"]]
[[br.com.markenson/csvjdbc "1.1.1-metabase-SNAPSHOT"]]

:profiles
{:provided
Expand Down
16 changes: 12 additions & 4 deletions csv/src/metabase/driver/csv.clj
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,21 @@
(defmethod sql-jdbc.sync/database-type->base-type :csv [_ database-type]
(database-type->base-type database-type))


(defn is-http [path] (if (clojure.string/starts-with? (clojure.string/lower-case path) "http") true false))

(defmethod sql-jdbc.conn/connection-details->spec :csv [_ {:keys [csv separator charset advanced]
:or {csv "arquivo.csv"}
:as details}]

(def strHttp (if (is-http csv) ":class:br.markenson.com.csvjdbc4metabase.readers.HttpCSVReader" ""))

(def customBaseUrl (if (is-http csv) (str "&customBaseUrl=" csv) ""))

(merge {:classname "org.relique.jdbc.csv.CsvDriver"
:subprotocol "relique:csv"
:subname (str csv "?separator=" separator "&charset=" charset advanced)
:subprotocol (str "relique:csv" strHttp)
:subname (str (if (is-http csv) "" csv) "?separator=" separator "&charset=" charset customBaseUrl advanced)
}
(dissoc details :csv :separator :charset :advanced))

(dissoc details :csv :separator :charset :customBaseUrl :advanced))
)

0 comments on commit a732f32

Please sign in to comment.