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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:14:13+00:00 2026-06-03T08:14:13+00:00

I have a rails app that was working fine with sqlite but upon switching

  • 0

I have a rails app that was working fine with sqlite but upon switching over to postgre I’m having an issue with this query:

User.find(1).ratings

Querying for just a works, e.g.

User.find(1)

produces

SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]

however if I append ratings like so:

User.find(1).ratings

produces

  User Load (1.4ms)  SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1  [["id", 1]]
  Rating Load (0.9ms)  SELECT "ratings".* FROM "ratings" WHERE "ratings"."user_id" = 1
PG::Error: ERROR:  operator does not exist: character varying = integer
LINE 1: ...CT "ratings".* FROM "ratings"  WHERE "ratings"."user_id" = 1
                                                                    ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT "ratings".* FROM "ratings"  WHERE "ratings"."user_id" = 1
ActiveRecord::StatementInvalid: PG::Error: ERROR:  operator does not exist: character varying = integer
LINE 1: ...CT "ratings".* FROM "ratings"  WHERE "ratings"."user_id" = 1
                                                                    ^

Whether a pass the :id as an int or string it still produces the above error. The models are set up so :ratings belongs_to User which has_many :ratings. Any ideas? Thanks in advance.

Versions: Rails 3.1.1, Ruby 1.9.2, devise 1.5.1

  • 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-03T08:14:14+00:00Added an answer on June 3, 2026 at 8:14 am

    This error

    ERROR: operator does not exist: character varying = integer

    usually means that you’re trying to compare two different data types for equality. Some platforms will let you do that by silently coercing one to the other. SQLite will, and it will let you do a lot of things that are not compliant with SQL standards. PostgreSQL usually won’t allow comparisons like this. Since it prints

    WHERE "ratings"."user_id" = 1
    

    in the error message, it’s telling you that, although you supplied an integer (1), the column ratings.user_id is actually a varchar().


    SQLite isn’t SQL. Here I use the universal data type “wibble”.

    sqlite> create table test (n integer not null, s wibble not null);
    sqlite> insert into test values (1, 'Wibble');
    sqlite> insert into test values ('Wibble', 1);
    sqlite> select * from test;
    1|Wibble
    Wibble|1
    

    SQLite is happy to let me insert “Wibble” into an integer column. That should at least give you pause, if not nightmares.

    PostgreSQL is free and available for many platforms. If you’re anticipating deployment on Heroku, I can’t see any reason not to install PostgreSQL and develop against it instead of using SQLite.

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

Sidebar

Related Questions

I have a rails app that is working fine except for one thing. When
I have a fantasy football league rails app that was working last year and
I have a rails app that has picked up a bit of traction, but
I have a rails app that uses heavily js (over 1MB total). I'd like
I have a rails app that has asynchronous processing, and I'm having trouble getting
I have a rails app with working reports that have tags. In the Report/Index.html.erb
I have a hash being posted to my Rails app that looks like this:
I have an app that I was first writing in rails 3.1 but in
I have a rails app that uses the following, rails 3.1, ruby 1.9.2, mysql,
I have a rails app that I have serving up XML on an infrequent

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.