Skip to content

Commit 1f1ff81

Browse files
committed
Address Turkish lower-case issue
1 parent 28e1999 commit 1f1ff81

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Changes coming in 0.7.10
22

3+
* Use a US-locale `lower-case` function to avoid problems in certain locales (e.g., Turkish). A similar issue has been fixed recently in both HoneySQL and `next.jdbc`.
34
* Clean up `db-spec` options that are passed to the JDBC connection manager as properties [JDBC-178](https://clojure.atlassian.net/browse/JDBC-178).
45
* Relax restriction on `create-table-ddl` column specs to allow numbers (as well as keywords and strings) [JDBC-177](https://clojure.atlassian.net/browse/JDBC-177).
56

src/main/clojure/clojure/java/jdbc.clj

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html"}
4545
(java.sql BatchUpdateException DriverManager
4646
PreparedStatement ResultSet ResultSetMetaData
4747
SQLException Statement Types)
48-
(java.util Hashtable Map Properties)
48+
(java.util Hashtable Locale Map Properties)
4949
(javax.sql DataSource)))
5050

5151
(set! *warn-on-reflection* true)
@@ -535,6 +535,13 @@ http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html"}
535535
:else
536536
identifiers))
537537

538+
(defn- lower-case
539+
"Converts a string to lower case in the US locale to avoid problems in
540+
locales where the lower case version of a character is not a valid SQL
541+
entity name (e.g., Turkish)."
542+
[^String s]
543+
(.toLowerCase s (Locale/US)))
544+
538545
(defn result-set-seq
539546
"Creates and returns a lazy sequence of maps corresponding to the rows in the
540547
java.sql.ResultSet rs. Loosely based on clojure.core/resultset-seq but it
@@ -551,7 +558,7 @@ http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html"}
551558
([rs] (result-set-seq rs {}))
552559
([^ResultSet rs {:keys [as-arrays? identifiers keywordize?
553560
qualifier read-columns]
554-
:or {identifiers str/lower-case
561+
:or {identifiers lower-case
555562
keywordize? true
556563
read-columns dft-read-columns}}]
557564
(let [rsmeta (.getMetaData rs)
@@ -1213,7 +1220,7 @@ http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html"}
12131220
Compiled with Clojure 1.7 or later -- uses clojure.lang.IReduce
12141221
Note: :as-arrays? is not accepted here."
12151222
[^ResultSet rs {:keys [identifiers keywordize? qualifier read-columns]
1216-
:or {identifiers str/lower-case
1223+
:or {identifiers lower-case
12171224
keywordize? true
12181225
read-columns dft-read-columns}}]
12191226
(let [rsmeta (.getMetaData rs)
@@ -1312,7 +1319,7 @@ http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html"}
13121319
([db sql-params] (reducible-query db sql-params {}))
13131320
([db sql-params opts]
13141321
(let [{:keys [identifiers keywordize? qualifier read-columns] :as opts}
1315-
(merge {:identifiers str/lower-case :keywordize? true
1322+
(merge {:identifiers lower-case :keywordize? true
13161323
:read-columns dft-read-columns}
13171324
(when (map? db) db)
13181325
opts)
@@ -1551,7 +1558,7 @@ http://clojure-doc.org/articles/ecosystem/java_jdbc/home.html"}
15511558
map, insert the rows into the database."
15521559
[db table rows opts]
15531560
(let [{:keys [entities transaction?] :as opts}
1554-
(merge {:entities identity :identifiers str/lower-case
1561+
(merge {:entities identity :identifiers lower-case
15551562
:keywordize? true :transaction? true}
15561563
(when (map? db) db)
15571564
opts)

0 commit comments

Comments
 (0)