Closed den1k closed 9 years ago
Hi, since the patches on naming are mine I had a look. Is there a chance you have a specified naming in the db-spec? 0.4.1 uses such a naming (if it`s there). If not - can you paste some code (appears to be working as expected over here)?
Steps to reproduce:
(use 'korma.core 'korma.db)
May 28, 2015 9:23:42 AM com.mchange.v2.log.MLog <clinit>
INFO: MLog clients using java 1.4+ standard logging.
=> nil
(require 'korma.config)
=> nil
(defdb db (h2 {:db "mem:issue298"}))
=> {:pool #<Delay@5ba590d5: :pending>, :options {:naming {:keys #<core$identity clojure.core$identity@37c9afa1>, :fields #<core$identity clojure.core$identity@37c9afa1>}, :delimiters ["\"" "\""], :alias-delimiter " AS ", :subprotocol "h2"}}
(select "INFORMATION_SCHEMA.TABLES" (limit 1))
=> ({:ID -8, :SQL nil, :TABLE_CLASS "org.h2.table.MetaTable", :REMARKS "", :TYPE_NAME nil, :TABLE_SCHEMA "INFORMATION_SCHEMA", :TABLE_CATALOG "ISSUE298", :TABLE_TYPE "SYSTEM TABLE", :LAST_MODIFICATION 20, :TABLE_NAME "HELP", :STORAGE_TYPE "CACHED"})
(korma.config/set-naming {:keys clojure.string/lower-case})
=> {:subprotocol "h2", :delimiters ["\"" "\""], :naming {:keys #<string$lower_case clojure.string$lower_case@34a50a81>, :fields #<core$identity clojure.core$identity@37c9afa1>}, :alias-delimiter " AS "}
(select "INFORMATION_SCHEMA.TABLES" (limit 1))
=> ({:ID -8, :SQL nil, :TABLE_CLASS "org.h2.table.MetaTable", :REMARKS "", :TYPE_NAME nil, :TABLE_SCHEMA "INFORMATION_SCHEMA", :TABLE_CATALOG "ISSUE298", :TABLE_TYPE "SYSTEM TABLE", :LAST_MODIFICATION 20, :TABLE_NAME "HELP", :STORAGE_TYPE "CACHED”})
In 0.4.0 the last select gives:
(select "INFORMATION_SCHEMA.TABLES" (limit 1))
=> ({:remarks "", :last_modification 20, :storage_type "CACHED", :table_class "org.h2.table.MetaTable", :table_type "SYSTEM TABLE", :table_schema "INFORMATION_SCHEMA", :sql nil, :id -8, :table_catalog "ISSUE298", :table_name "HELP", :type_name nil})
db spec contains identity naming. Results still seems normal to me.
The problem is that it is not given by the user and changing the global config doesn't have any effect.
I think this could be fixed by not assigning default identity naming to db spec when it's created.
I will try to submit a PR later to 'strip' :options when using defdb
. If you just pass the h2
spec to default-connection
it works exactly as advertised.
Finally got to a solution. Can't finish it today but I could use the feedback if you have the time.
Fixed in 0.4.2
Works in 4.0 but not 4.1. Using Clojure 1.7.0-RC1