Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8160157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:09:12+00:00 2026-06-06T18:09:12+00:00

I am using SQLite3 for development and PostgreSQL for deployment. However, I am facing

  • 0

I am using SQLite3 for development and PostgreSQL for deployment. However, I am facing the following problem:

My simple search using SQLite3:

def self.search(search)
    if search
      find(:all, :conditions => ["style LIKE ? OR construction LIKE ?", "%#{search}%", "%#{search}%"])
    else
      find(:all)
    end
end

However, it doesn’t work for PostgreSQL, and I need to replace the LIKE for ILIKE to solve the problem:

def self.search(search)
    if search
      find(:all, :conditions => ["style ILIKE ? OR construction ILIKE ?", "%#{search}%", "%#{search}%"])
    else
      find(:all)
    end
end

Is there a “Ruby way” to do these searches across any database?

EDIT – based on your answers I don’t believe I will find a generic Ruby solution for that.

I have followed the Ruby on Rails Tutorial: Learn Rails by Example – by Michael Hartl, where the final Gemfile shows both databases… well, disappointing…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:09:13+00:00Added an answer on June 6, 2026 at 6:09 pm

    The root of the problem lies here:

    I am using SQLite3 for development and PostgreSQL for deployment.

    That’s a bad idea™. You will keep running into incompatibilities – or worse: not realize some until damage is done.
    Use the same RDBMS (PostgreSQL) for development and production and save yourself the pointless trouble.

    While you are stuck with your unfortunate setup, there is a simple fix:

    lower(style) LIKE lower(?)
    

    Works on both platforms alike.

    Drop the right-hand lower() if you provide a lower-case search-pattern.

    In standard SQLite lower(X) only folds ASCII letters. Quoting the chapter Core Functions in the SQLite manual:

    The lower(X) function returns a copy of string X with all
    ASCII characters converted to lower case. The default built-in lower()
    function works for ASCII characters only. To do case conversions on
    non-ASCII characters, load the ICU extension.

    Bold emphasis mine.

    PostgreSQL lower(X) works with UTF-8 out of the box.

    As a welcome side effect, you can speed up that query in PostgreSQL with an index on the expression lower(style), which will be faster than using ILIKE and a basic index on style.

    Also, since PostgreSQL 9.1 you can use a GIN or GIST index with the pg_trgm extension to speed up any LIKE and ILIKE query – trigram indexes are case-insensitive. Details:

    • Similar UTF-8 strings for autocomplete field
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I used Heroku in the past with Rails 3.0.9 using sqlite3 in development (locally).
I am new on iPhone development. I am making an app, using sqlite3 for
I am switching from using SQLite3 to PostgreSQL, and hoped that I could populate
rails 2.3.4, sqlite3 I'm trying this Production.find(:all, :conditions => ["time > ?", start_time.utc], :order
OK, I've been using sqlite3 as development successfully for this tiny rails 3.1 project,
I have the following statement in Rails 3 using an SQLite3 database: word =
I've been using sqlite3 for my database under development and my app has gotten
I am following the Rails Tutorial with the database set up using postgreSQL so
I am using SQLite3 for iPhone development and I'm attempting to wrap a few
I used to develop on SQLite3 and deploy on PostgreSQL . However, after this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.