funcool / clojure.jdbc

JDBC library for Clojure
http://funcool.github.io/clojure.jdbc/latest/
Apache License 2.0
105 stars 26 forks source link

Why fetch result column-name are lowercased ? #33

Closed ChinaXing closed 7 years ago

ChinaXing commented 7 years ago

rds-test> (jdbc.core/fetch conn ["select haNetworkTimeout from InstanceGroup"])
[{:hanetworktimeout 5}]

the column name is : "haNetworkTimeout", but result key is : "hanetworktimeout"

why do this conversion ?

niwinz commented 7 years ago

Because, the column names usually are case insensitive in the database, and in most cases is the database that returns the column names normalized to lowe case.

Let see a little example using postgresql:

test=# create table test (aA int);
CREATE TABLE
test=# insert into test (aa) values (1);
INSERT 0 1
test=# insert into test (aa) values (2), (3), (4);
INSERT 0 3
test=# select * from test;
 aa 
----
  1
  2
  3
  4
(4 rows)

test=# select aa,AA,aA from test;
 aa | aa | aa 
----+----+----
  1 |  1 |  1
  2 |  2 |  2
  3 |  3 |  3
  4 |  4 |  4
ChinaXing commented 7 years ago

This is not what MySQL presents. Maybe keep what database returned is a better way?

niwinz commented 7 years ago

You can provide your own behavior, providing the {:identifiers identity} option