[clj-record-dev] Table names with underscores

2 views
Skip to first unread message

Jim Menard

unread,
May 16, 2010, 10:23:50 PM5/16/10
to clj-record-dev
I've just started using clj-record, and I like it. After starting to
write my own version of a very simplified Active Record, I discovered
clj-record and was very happy and relieved.

However, I'm getting bitten by underscores in table and column names.
I think that the answer is for clj-record to translate all underscores
to dashes in all table and column names, but I'm not sure.

Does anybody else who uses clj-record have underscores in table names
or foreign key names? To be honest, I can't fully describe the problem
I'm having because I've tried so many combinations of dashes and
underscores that my head is spinning :-)

For me, it seems to boils down to a problem with using either dashes
or underscores in model names (like "my.package.user-test" or
"my.package.user_test") and association names. You can't have a model
named my.package.user_test because Clojure/Swank won't find it if it's
in a file named my/package/user_test.clj --- the underscore is changed
to a dash and I end up seeing an error message something like "package
user_test does not exist". However, you can't have a model named user-
test because...because...I forgot why---my head is still spinning.

tl;dr version: how do I name models, tables, and foreign keys in the
Clojure code where the database uses underscores?

--
Jim Menard, ji...@io.com

Jim Menard

unread,
May 17, 2010, 9:03:31 AM5/17/10
to clj-record-dev
I've forked clj-record (http://github.com/jimm/clj-record) and added a
new feature: dashes in model and association names are translated to
underscores in table and column names. There are also tests for this
new behavior.

Jim
> Jim Menard, j...@io.com

John D. Hume

unread,
May 17, 2010, 10:10:31 AM5/17/10
to clj-rec...@googlegroups.com
Hi Jim,
Thanks for this. I'll try to get it pulled in later this week.
-hume.
--
http://elhumidor.blogspot.com/
Reply all
Reply to author
Forward
0 new messages