Dear list,
I’m having a bit of a problem and it took me a while to narrow it
down. I’m working with a database that has a prescribed naming
convention for the columns. Unfortunately, this naming convention
includes the use of curly braces in the names of columns. So, for
example, I might have a column called COLUMN[{_01}]. Inside the MySQL
client, this presents no problems. The statement:
SELECT COLUMN[{_01}]
FROM TABLE;
works just fine and as it did when I used it with ActiveRecord via Ruby.
However, when I switched to JRuby, I got a nasty surprise:
Unknown column Column[] in statement ‘SELECT COLUMN[{_01}]
FROM TABLE’
which seemed kind of odd to me because, well, COLUMN[] does not appear
in the statement. That’s when I learned about SQL escape sequences and
that JDBC processes SQL escape sequences by default which means that
the jdbcmysql adapter is processing escape sequences by default. Using
JDBC directly, I can fix my problem as follows:
stmt = conn.createStatement
stmt.setEscapeProcessing( false)
rs = stmt.executeQuery(“SELECT COLUMN[{_01}]
FROM TABLE”)
What I would like to hear is that there is an escape_processing
parameter to setting up ActiveRecord as in:
development:
adapter: jdbcmysql
escape_processing: false
database: testapp_development
username: root
password: root
However, I doubt this is the case. I did a bit of digging in the gems
and I just couldn’t identify where I could put the expression:
stmt.setEscapeProcessing( false)
in the code. Perhaps a list reader could be of some assistance? Is
there an alternative.
Cheers,
Steve