Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

482
Views
What does "~~ *" mean in Ruby?

It used in this part of code:

some_list.where("'#{@new_params[:email]}' ~~* name").any?

I tried to use google search, but i found only description of ~ rxp and this same unclear for me (especially in example). I had no experience with Ruby earlier, sorry if question is stupid.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

~~* doen't actually have anything to with Ruby. Its the Postgres specific ILIKE operator for pattern matching.

This code is also a textbook example of a SQL injection vulnerability. The user input should be parameterized.

some_list.where("? ~~* name", @new_params[:email]).any?

This code is also pretty bizarre in that it has a Yoda condition. Normally you would write it as:

some_list.where("name ~~* ?", @new_params[:email]).any?
over 4 years ago · Santiago Trujillo Report

0

That has nothing do do with ruby. You construct a sql query and pass it into the #where method therefor it is a PostgreSQL operator.

The operator ~~ is equivalent to LIKE, and ~~* corresponds to ILIKE. There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. All of these operators are PostgreSQL-specific.

That's what you are passing into it:

"foo@bar.com ILIKE name"

over 4 years ago · Santiago Trujillo Report

0

Any string in a where clause will be put into the SQL query which is then handed off to the database. So the ~~* syntax is not ruby, but SQL. My guess would be, that you are using Postgres as a DB, because:

The operator ~~ is equivalent to LIKE, and ~~* corresponds to ILIKE. There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. All of these operators are PostgreSQL-specific.

Taken from: https://www.postgresql.org/docs/current/functions-matching.html#FUNCTIONS-LIKE

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!