Issues with query filter postgresql

Hii have this app

it have value BANISTMO but no results are found

here is my query:

SELECT 
  c.id, 
  c.idclave_nombre, 
  o.fechaproxima_llamada, 
  c.ubicacion, 
  c.nombres, 
  c.apellidos, 
  c.cedula, 
  c.sector, 
  c.empresa, 
  c.acreedor, 
  c.analista, 
  c.sucursal, 
  o.motivo, 
  c.ps, 
  c.fecha_nacimiento, 
  DATE_PART(
    'YEAR', 
    AGE(
      CURRENT_DATE, c.fecha_nacimiento
    )
  ) as edad, 
  c.sexo, 
  c.usuario, 
  c.notas, 
  CURRENT_DATE - CAST(
    c.fecha_seguimiento AS DATE
  ) as TE 
  
FROM 
  tbl_clientes c 
  INNER JOIN tbl_observaciones o ON c.idclave_nombre = o.idclave_nombre 

WHERE 
  (
    {{ ! cedula.value }} 
    OR c.cedula ILIKE {{ '%' + cedula.value + '%' }}
  ) 
  AND (
    {{ ! sector.value }} 
    OR c.sector = {{ sector.value }}
  ) 
    AND (
    {{ ! acreedor.value }} 
    OR c.acreedor = {{acreedor.value}}
  ) 
  AND (
    {{ ! analista.value }} 
    OR c.analista ILIKE {{ '%' + analista.value + '%' }}
  ) 
  AND (
    {{ ! ubicacion.value }} 
    OR c.ubicacion = {{ ubicacion.value }}
  ) 
  AND (
    {{ ! motivo.value }} 
    OR o.motivo = {{ motivo.value }}
  ) 
  AND (
    {{ ! nombre.value }} 
    OR c.nombres ILIKE {{ '%' + nombre.value + '%' }}
  ) 
  AND (
    {{ ! apellido.value }} 
    OR c.apellidos ILIKE {{ '%' + apellido.value + '%' }}
  )
  AND (
    {{ ! notas.value }} 
    OR c.notas ILIKE {{ '%' + notas.value + '%' }}
  )
  AND (
    {{ !(rangodefecha.value.start) }} 
    OR (
      o.fechaproxima_llamada <= {{moment(rangodefecha.value.end).format('YYYY-MM-DD') }} 
      AND o.fechaproxima_llamada >= {{moment(rangodefecha.value.start).format('YYYY-MM-DD') }}
    )
  ) 
  AND o.fechaproxima_llamada IS NOT NULL 
  AND o.fechaproxima_llamada != '' 
ORDER BY 
  TO_DATE(
    o.fechaproxima_llamada, 'YYYY-MM-DD'
  ) ASC
  
LIMIT {{table1.pagination.pageSize}} 
OFFSET {{table1.pagination.offset}}

all my filters works but not that one

    AND (
    {{ ! acreedor.value }} 
    OR c.acreedor = {{acreedor.value}}
  )

if i do my query like this

it works good, what im missing? @ScottR @matth @victoria @PeteTheHeat

pd: i saw my value have a blank space after BANISTMO after the letter O, so i tried put a ILIKE but still wont work

  AND (
    {{ ! acreedor.value }} 
    OR c.acreedor ILIKE {{ '%' + acreedor.value + '%' }}
  )

IN all of your checks for values where they are null..remove the space...
{{ ! cedula.value }} should be {{ !cedula.value }}

this also doesn't seem correct ...
{{ !(rangodefecha.value.start) }}
should be
{{ !rangodefecha.value.start}}

1 Like

is done, but still doest works :frowning:

what i did was to remove blank space withing the postgresql table and now its working.

2 Likes