Rails AR/Oracle Unit Test: [6892] failed (but getting better)

"bitsweat" has given AR/Oracle some love, but it's still unhappy...

http://dev.rubyonrails.org/changeset/6892

The Oracle adapter's quote_column_name:

        # camelCase column names need to be quoted; not that anyone using Oracle
        # would really do this, but handling this case means we pass the test...
        def quote_column_name(name) #:nodoc:
          name.to_s =~ /[A-Z]/ ? "\"#{name}\"" : name
        end

Presumably to avoid having your DBA lowercase existing column names?

jeremy

Jeremy Kemper wrote:

The Oracle adapter's quote_column_name:

        # camelCase column names need to be quoted; not that anyone using Oracle
        # would really do this, but handling this case means we pass the test...
        def quote_column_name(name) #:nodoc:
          name.to_s =~ /[A-Z]/ ? "\"#{name}\"" : name
        end

Presumably to avoid having your DBA lowercase existing column names?

Sort of. Oracle is generally case-insensitive, and 99.9% of folks don't quote column names, effectively making them uppercase. The implementation above satisfied the test case of somebody using a mixed-case name, which is very unexpected when using Oracle.

It's also bad form to use a reserved word for a column name, even if that's technically possible by quoting the name. Quoting all names in order to make this work would have a very negative impact, as it would break the current nice behavior of lowercase column names in Ruby and case-insensitive names in Oracle.

I can either provide a patch that quotes column names only if they're reserved words, or just punt and have this specific test not run for Oracle.

Thoughts?

Note that this is per SQL-spec. (Another data point: for historical reasons, PostgreSQL downcases unquoted identifiers.)

Michael Glaesemann
grzm seespotcode net