Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

486
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda