Camel case support for column names lost in ormlite-android > version 4.36?

379 views
Skip to first unread message

rzimmer

unread,
Mar 28, 2012, 11:45:37 AM3/28/12
to ORMLite Android Users
Hi,

I have some database fields following the Java camel case convention.
After upgrading from 4.36 to a 4.37 (or 4.38), my robolectric unit
tests fail with an "java.sql.SQLException: Unknown field 'profileId'
from the Android sqlite cursor, not in:[profileid, ...]".

I suppose it has something to do with this change in 4.37: * ANDROID:
Fixed a bug with Android API lookup of column names with periods.
Thanks to Sebastian Roth. Bug #3509386.

Or are camel cased database fields supposed to have an explicit
defined column name? I honestly don't want to redefine column names
for all my fields...

Nevertheless, thanks a lot for this great library!

Gray Watson

unread,
Mar 28, 2012, 6:29:17 PM3/28/12
to ormlite...@googlegroups.com
Yeah this seems to be a change that was introduced in 4.37. I can return it to that behavior but I'm not sure if that is the right way to go.

If you had an object whose field name was "camelcase" in the database, even though the Java field name was "camelCase", since 4.37 you aren't be able to retrieve it from the database. It throws the "Unknown field" exception that Roman got below.

I could add the case insensitive column lookups back in but it would mask other problems. For example, if you wanted to search for the field "camelCase", it wouldn't work -- you'd have to specify it as "camelcase" in the eq(field, value) method. In addition, methods such as the Dao.queryForMatching() would not work at all unless you specified the columnName in the @DatabaseField.

Any thoughts/comments here? I guess keeping backwards compatibility should be the goal but I don't like the asymmetry.
gray

David Fire

unread,
Mar 28, 2012, 7:36:19 PM3/28/12
to ormlite...@googlegroups.com
my humble opinion, this should be case sensitive.
Almost all languages work like that, and Android Java is not the exception, why mess the stuff?
the code will be cleaner at the end.
David

2012/3/28 Gray Watson <256...@gmail.com>



--
 (\__/)
(='.'=)This is Bunny. Copy and paste bunny into your
(")_(")signature to help him gain world domination.

Reply all
Reply to author
Forward
0 new messages