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

280
Views
Cómo aplicar LOWER() a una referencia en Objection

Estoy usando una declaración like where en mi consulta como esta:

 import { ref } from 'objection' // [...] query = query.where(ref('data.nested_data').castText(), 'like', `%${value}%`)

Y está funcionando bien. La consulta resultante se ve así:

 WHERE CAST("data"#>>'{nested_data}' AS text) like '%example%'

Ahora quiero usar la función LOWER() en la clave, para poder encontrar resultados que no distingan entre mayúsculas y minúsculas. Entonces mi consulta ahora se ve así:

 import { ref, raw } from 'objection' // [...] query = query.where(raw(`LOWER(${ref('data.nested_data').castText()})`), 'like', `%${value.toLowerCase()}%`);

Pero esto da como resultado la siguiente consulta SQL (lanzando un error):

 WHERE LOWER([object Object]) like $1 -- ERROR: syntax error at or near "[" -- LINE 6: WHERE LOWER([object Object]) like $1

¿Hay alguna manera de lograr lo que estoy buscando? Prefiero no usar una consulta sin procesar ya que mi tipo para emitir es dinámico

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Las personas que mantienen Objection me ayudaron a resolver este problema en github .

La sintaxis correcta es:

 const key = ref('data.nested_data').castText(); query = query.where(raw('LOWER(??)', [key]), 'like', `%${value.toLowerCase()}%`);
about 4 years ago · Juan Pablo Isaza 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!