Austin Ziegler
11/24/2004 12:27:00 PM
On Wed, 24 Nov 2004 19:48:18 +0900, Gavin Sinclair
<gsinclair@soyabean.com.au> wrote:
> On Wednesday, November 24, 2004, 9:23:09 PM, David wrote:
> > Jamis Buck had an example from Oracle also being case sensitive, so it
> > seems to be somewhat more widespread than just MySQL. And as I said,
> > Active Record was founded on MySQL, so when behavior differs between
> > RDBMS, AR will side by MySQL by default (strong pressures might revert
> > that default, but I don't think this is a strong pressure).
> I was suprised with Jamis's Oracle examples; I always thought Oracle
> was case-insensitive up the wazoo. But I guess I never tried quoting
> table names etc. (yeah, *that's* intuitive...)
That's the point -- SQL92 introduced the quoted format to specifically
allow for case sensitivity. If ActiveRecord is generating its SQL such
that it does:
SELECT "foo" FROM "CREDIT_RATING";
Then it's doing it right -- if ugly. The problem is that the SQL92
syntax requires that if you are going to use quoted SQL identifier
names, you ALWAYS have to use quoted SQL identifier names, even when
creating the tables. See, with Jamis's example of "CREDIT_RATINGS" and
"credit_ratings", both of those tables would have to be quoted in all
SQL regarding that. I don't know if ActiveRecord does that, to be
quite honest -- I haven't delved into the details. If I have
credit_ratings and "CREDIT_RATINGS", then there's no way that I can
get at "CREDIT_RATINGS" unless I always quote it. Simply doing:
1) SELECT * FROM CREDIT_RATINGS
2) SELECT * FROM credit_ratings
3) SELECT * FROM "CREDIT_RATINGS"
1 and 2 are the same. 3 is the only one that refers to the
"CREDIT_RATINGS" table.
The reality is that MySQL is a crap database that doesn't follow
proper SQL92 conventions, and the semantics of this cause a mismatch
in expectations and behaviours. Even SQLServer doesn't behave as badly
as MySQL.
> Also, I was surprised by Austin's use of Sybase to back up the "SQL
> databases are case-insensitive" claim. When I worked with Sybase ~6
> years ago, it was certainly case-sensitive. The meme in the office at
> the time was that Sybase was different from most other DBs in this
> regard, and we had to be careful about this when migrating data.
I googled for answers because all of my Oracle references are now at
work. I understand that David is using MySQL semantics here, but as
I've said, MySQL is wrong. If the goal is to make ActiveRecord more
widely accepted, then the naming convention thing is going to have to
be dealt with. Frankly, I have stuff that I'd love to do using
ActiveRecord -- but can't even consider it with this broken behaviour.
-austin
--
Austin Ziegler * halostatue@gmail.com
* Alternate: austin@halostatue.ca