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 8522205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:03:09+00:00 2026-06-11T07:03:09+00:00

I am using a SQLite3 database in development, and now have started to use

  • 0

I am using a SQLite3 database in development, and now have started to use heroku to host my app. Heroku only supports PostgreSQL which I have modified in my GEM file

group :development, :test do
 gem 'sqlite3'
end
group :production do
  gem 'pg'
end

Now, everything is working as it should except when I query a date, I get this error

    ActionView::Template::Error (PG::Error: ERROR:  invalid input syntax for type date: ""
2012-09-12T10:03:03+00:00 app[web.1]: 
2012-09-12T10:03:03+00:00 app[web.1]: LINE 1: ...-12' AND '2012-09-12' OR DATE(start_date) BETWEEN '' AND '')...
2012-09-12T10:03:03+00:00 app[web.1]:                                                              ^
2012-09-12T10:03:03+00:00 app[web.1]:     137: <% if @project_search.total_entries > 0 %>
2012-09-12T10:03:03+00:00 app[web.1]:     136: 
2012-09-12T10:03:03+00:00 app[web.1]: : SELECT COUNT(*) FROM "projects"  WHERE (client LIKE '%%' AND industry LIKE '%%' AND role LIKE '%%' AND tech LIKE '%%' AND business_div LIKE '%%' AND project_owner LIKE '%%' AND exception_pm LIKE '%%' AND status LIKE '%%' AND (DATE(start_date) BETWEEN '2011-09-12' AND '2012-09-12' OR DATE(start_date) BETWEEN '' AND '') AND keywords LIKE '%%')):
2012-09-12T10:03:03+00:00 app[web.1]:     138: <% if @search_performed %>
2012-09-12T10:03:03+00:00 app[web.1]:     140: <style>
2012-09-12T10:03:03+00:00 app[web.1]:     139:

Here is my project.rb, as I think this is where I need to change something:

class Project < ActiveRecord::Base
  attr_accessible :edited_first_name, :edited_last_name, :first_name, :last_name, :business_div, :client, :customer_benifits, :edited_date, :end_date, :entry_date, :exception_pm, :financials, :industry, :keywords, :lessons_learned, :project_name, :project_owner, :role, :start_date, :status, :summary, :tech

#validates_presence_of :business_div, :client, :customer_benifits, :end_date, :exception_pm, :financials, :industry, :keywords, :lessons_learned, :project_name, :project_owner, :role, :start_date, :status, :summary, :tech



def self.search(search_client, search_industry, search_role, search_tech, search_business_div, search_project_owner, search_exception_pm, search_status, search_start_date_dd, search_start_date_A, search_start_date_B,  search_keywords) 
  return scoped unless search_client.present? || search_industry.present? || search_role.present? || search_tech.present? || search_business_div.present? || search_project_owner.present? || search_exception_pm.present? || search_status.present? || search_start_date_dd.present?  || search_start_date_A.present?  || search_start_date_B.present?  || search_keywords.present?


todays_date = DateTime.now.to_date

if !search_start_date_A.blank? or !search_start_date_B.blank?
    search_start_date_A = Date.parse(search_start_date_A).strftime("%Y-%m-%d")
    search_start_date_B = Date.parse(search_start_date_B).strftime("%Y-%m-%d")
    todays_date = ""
    end

if search_start_date_dd.blank?
    todays_date = ""
end


if (search_start_date_A.blank? or search_start_date_B.blank?) and search_start_date_dd.blank?

where(['client LIKE ? AND industry LIKE ? AND role LIKE ? AND tech LIKE ? AND business_div LIKE ? AND project_owner LIKE ? AND exception_pm LIKE ? AND status LIKE ? AND keywords LIKE ?', 
      "%#{search_client}%", "%#{search_industry}%" , "%#{search_role}%" , "%#{search_tech}%" , "%#{search_business_div}%" , 
      "%#{search_project_owner}%" , "%#{search_exception_pm}%" , "%#{search_status}%", 
       "%#{search_keywords}%"
    ])

else

where(['client LIKE ? AND industry LIKE ? AND role LIKE ? AND tech LIKE ? AND business_div LIKE ? AND project_owner LIKE ? AND exception_pm LIKE ? AND status LIKE ? AND (DATE(start_date) BETWEEN ? AND ? OR DATE(start_date) BETWEEN ? AND ?) AND keywords LIKE ?', 
      "%#{search_client}%", "%#{search_industry}%" , "%#{search_role}%" , "%#{search_tech}%" , "%#{search_business_div}%" , 
      "%#{search_project_owner}%" , "%#{search_exception_pm}%" , "%#{search_status}%", 
      search_start_date_dd, todays_date , search_start_date_A, search_start_date_B, "%#{search_keywords}%"
    ])
end
end


def self.paginated_for_index(projects_per_page, current_page)
    paginate(:per_page => projects_per_page, :page => current_page)
  end

end

It seems SQLite3 could handle ” as an empty date, but PG can’t

Does anyone have some solution to this?

I am new to rails so please remember this when answering. Thanks in advance.

  • 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-11T07:03:11+00:00Added an answer on June 11, 2026 at 7:03 am

    NULL and '' (the empty string) are different things. Some databases, like MySQL and apparently SQLite, allow you to treat them as the same thing, but they are not. '' is not a valid date. PostgreSQL won’t accept another common MySQL-ism, 0000-00-00, either; watch out for that in case you’re used to using that as a placeholder or “invalid” value.

    You need to fix your application so that it sends NULL for null dates. I expect that setting the date to the application-level null/nil value (Ruby seems to use nil as its null-value) instead of to "" will do the trick.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been using sqlite3 for my database under development and my app has gotten
I have been happily developing my application locally and using sqlite3 as database only
hi i am working on a django python application using sqlite3 database. I have
I was newbie in using sqlite database android. and now I have a problem
I have the following statement in Rails 3 using an SQLite3 database: word =
I want to use PostgreSQL locally since I have to use it on Heroku.
My development database is SQLite but I deploy my app to Heroku and they
I am able to create a connection to a local sqlite3 database ( Using
This is how i creted my Database using sqlite Pro:~ dd$ sqlite3 db.db SQLite
I am using sqlite database for iphone app. but its crash on while loop

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.