SQL query different on production server than dev server

I’m having an odd problem on the production server that does not occur
in development.

I’m using the TextSearch code from here:
http://wiki.rubyonrails.org/rails/pages/TextSearch
to search on my Product model.

In development, when I search for “Ruby R.” via my form, I get this
code:

Processing SearchController#results (for 127.0.0.1 at 2007-02-24
12:27:18) [POST]

Parameters: {“search_terms_form”=>“ruby rails”, “commit”=>“Search”,
“action”=>“results”, “controller”=>“search”}
SELECT * FROM products WHERE (((lower(title) like ‘%ruby%’ or
lower(description) like ‘%ruby%’ or lower(author) like ‘%ruby%’ or
lower(isbn) like ‘%ruby%’ or lower(publisher) like ‘%ruby%’) and
(lower(title) like ‘%rails%’ or lower(description) like ‘%rails%’ or
lower(author) like ‘%rails%’ or lower(isbn) like ‘%rails%’ or
lower(publisher) like ‘%rails%’)))

However, the very same code in production gives this bizarre code:

Processing SearchController#results (for 203.51.51.225 at 2007-02-24
12:24:12) [POST]

Parameters: {“search_terms_form”=>“ruby rails”, “commit”=>“Search”,
“action”=>“results”, “controller”=>“search”}
SELECT * FROM products WHERE
(((lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(title)))))))))))))))))
like ‘%ruby%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(description)))))))))))))))))
like ‘%ruby%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(author)))))))))))))))))
like ‘%ruby%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(isbn)))))))))))))))))
like ‘%ruby%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(publisher)))))))))))))))))
like ‘%ruby%’) and
(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(title)))))))))))))))))
like ‘%rails%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(description)))))))))))))))))
like ‘%rails%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(author)))))))))))))))))
like ‘%rails%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(isbn)))))))))))))))))
like ‘%rails%’ or
lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(lower(publisher)))))))))))))))))
like ‘%rails%’)))

Now, the first query runs perfectly.

I’m at a loss as to how the same code generates such different
queries.

Any clues appreciated.

Richard S.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs