Austin Ziegler wrote:
> 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.

I'm definately not a DB expert, but I believe in this case Oracle, at 
least, *is* case sensitive.  Consider:

   create table "credit_rating" (
     ...
   );

   create table "CREDIT_RATING" (
     ...
   );

The above would create two distinct tables.

The keywords are case insensitive, but the column and table names can be 
made case sensitive by putting them in quotes. If you omit the quotes, 
the identifier is uppercased automatically.

> 
> 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.

That's a bit strong, Austin. David made a decision and has enforced that 
decision. If you want to use database identifiers that are mixed case, 
you are in no way compelled to use ActiveRecord. AR was designed (and 
David has made this clear repeatedly) to enforce certain application 
design decisions, to make it easier to rapidly build apps. I believe he 
has also said, specifically, that he wants to avoid the trap of having 
AR "do everything".

> 
> 
>>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.

Again, not necessarily. Some DB's would see those as the same, others 
might not, depending on how the tables were created.

I'm not saying I agree with all of David's decisions regarding AR and 
Rails, but where I disagree it is a matter of personal preference. He 
made certain decisions, and they _work_. That's really what matters, I 
think.

- Jamis

-- 
Jamis Buck
jgb3 / email.byu.edu
http://www.jamisbuck.org/jamis