rsim/oracle-enhanced — pull request #371 by mxhold (2013-11-13 20:08:42+00:00)
Title: Prevent text being replaced with empty_clob() when quoting if the value is not empty

The initial problem that we ran into was that doing a Ransack search in a Rails 4 app on a text column was always resulting in a query with empty_clob() replacing the actual query value.

Searching all the way down into the Oracle Enhanced Adapter, we found this piece of code that looks like it always replaces text type columns with "empty_clob()" which seems to be the source of the problem. We found that a column is not passed as an argument to the quote() method in normal Rails calls (which is perhaps why this hasn't caused problems previously), only when the query is built with Arel:

$ model = Model.arel_table
$ matcher = model[:attribute].matches("%foo%")
$ Model.where(matcher).to_sql #=> ... WHERE model.attribute LIKE empty_clob())

I'm not particularly familiar with this code base but this fix resolved the issue for us. Maybe a similar fix would be needed for the binary column type too?