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

  • Home
  • SEARCH
  • 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 9237039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T07:26:40+00:00 2026-06-18T07:26:40+00:00

Currently I’m trying, in a rails 3 application, to select all objects where two

  • 0

Currently I’m trying, in a rails 3 application, to select all objects where two arrays have some overlap.

I’ve tried the following:

Contact.where("possible_unique_keys && ?" c.possible_unique_keys)

Which gives:

array value must start with "{" or dimension information

So I tried to convert the latter record into a postgresql array, like so:

Contact.where("possible_unique_keys && string_to_array(?)", c.possible_unique_keys)

Which gives:

operator does not exist: character varying[] && text[]

How so I get both arrays to a format that will correctly evaluate &&?

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

    I think I’ve solved it for now, and come up with a way to build a query from a Ruby array to a postgresql array (thanks in part to this bit of code written for rails/postgresql interoperability.

    Given a list of strings [“bill”, “joe”, “stu”, “katie”, “laura”], we have to do a little bit in the way of acrobatics to get postgresql to recognize them. This is a solution to construct the request.

    request = "SELECT * from  Contacts where possible_unique_keys && \'{"
    list.each do |key|
        key.gsub("'", "\\'")
        if key == c.possible_unique_keys.last
            request << "\"#{key}\"}\'"
        else
            request << "\"#{key}\", "
        end
     end
     dupes = Contacts.find_by_sql(request)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently i have a node.js and socket.io application in development on my local machine
Currently I am re-vamping some code that I currently have written something like this:
Currently I'm trying to parse some html and return an array with the values
Currently I am writing a program for an introductory Java class. I have two
Currently I am working on small application in asp.net mvc. It is a some
Currently working on a multi-tenant application, have an issue in generating identifier in a
Currently I have two projects that are separate from one another. The first is
Currently I have the following code to update the NSLevelindicator: [self.headerIndicator selfFloatValue:heightValue] Is there
Currently, I have several queries that need to run in order (some create temp
Currently where I work we have the following set-up (for ASP.NET web-development) using Git

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.