On Wed, 24 Nov 2004 07:01:17 +0900, David Heinemeier Hansson
<david / loudthinking.com> wrote:
>> I haven't seen this myself, but from something said by others, it
>> appears that ActiveRecord may actually have a few minor issues
>> with cased table and column names.
> Yes, this issue is that Active Record dictates you to use
> lower-case ;). Neither databases nor Ruby is case-insensitive, I
> don't think I want to put that in Active Record. The idea is that
> the table and the class bear close resemblance.

Erm. SQL databases *are* case-insensitive on the names. MySQL may
not be, but that's a problem with MySQL, not RDBMSes in general. In
Oracle, at least, there's no difference between ID, Id, and id for a
column or table name.

Essentially, David, this is a *problem* with ActiveRecord.
ActiveRecord is in the wrong here if it's being case-sensitive to
the database's meta-data in the general case. 

I don't disagree with many other design decisions you've made --
enforce the lower-case behaviour in the Ruby side, certainly, and I
agree with the decision for underscores -- but the reality is that
ActiveRecord is in the wrong for case-sensitivity on the database
side.

> Hence, Active Record also proclaims that thy shall use lower-cased
> and underscores for composite words. So CreditRating is turned
> into credit_ratings.

That's fine, for the Ruby side. But credit_ratings and
CREDIT_RATINGS on the database side are one and the same.
ActiveRecord must be smart enough to do this.

> If you really wanted to, you could overwrite all of that, though.
> You can overwrite the id column used with Model.id_column() and
> the table name with Model.table_name().

I shouldn't have to, for this. I agree with your assertions
regarding naming schemes in general (e.g., it has to be
credit_ratings and not credit_rating) but -- at the risk of majorly
repeating myself :) -- SQL databases are case insensitive. It's a
MySQL so-called extension (really, it's a screwup on their part)
that makes SQL case-sensitive on their part.

Compare:
http://qurl.net/7z (MySQL)
http://qurl.net/7y (MySQL)
http://qurl.net/7x (Sybase: see "Case sensitivity of identifiers")
http://qurl.net/7A (FirebirdSQL: see "Double-quoted identifiers")

Sorry, but I lived and breathed real RDBMS systems for a few years,
and MySQL is wrong (and inconsistent! -- it depends on the
underlying filesystem, not on the inherent nature of the database).
If ActiveRecord's behaviour is based on that, then ActiveRecord
needs to change.

-austin
-- 
Austin Ziegler * halostatue / gmail.com
               * Alternate: austin / halostatue.ca