PostgreSQL: ERROR: operator does not exist: bigint ~~ * unknown

0

I am making a filter with pagination in cakephp, however when I type a phone number to search, it returns the following error:

  

Error: SQLSTATE [42883]: Undefined function: 7 ERROR: operator does not exist: bigint ~~ * unknown LINE 1: ... om"."status_id_destino") WHERE "User"."telefone" ILIKE '%53 ... ^

     

HINT: No operator matches the given name and argument type (s). You might need to add explicit type casts.

Any value that I type in this field, I get this error!

(NOTE: The other filters work normally, only this is a INTEGER field that is not working)

Edited: Adding query snippet:

 SELECT "User"."id", "User"."telefone", "User"."email" .... etc ...
 FROM "public"."users" AS "User" .... etc ...
 WHERE "User"."telefone" ILIKE '%5332733535%'
        AND "Home"."ativo" = 'TRUE'
        AND "Home"."status_id_destino"
             IN (1, 2, 3, 4, 5, 6, 7, 8, 9)
 ORDER BY "Ose"."id" asc LIMIT 20
    
asked by anonymous 28.12.2016 / 12:23

1 answer

0

Response: As discussed, it can be done this way:

 SELECT "User"."id", "User"."telefone", "User"."email" .... etc ...
 FROM "public"."users" AS "User" .... etc ...
 WHERE "User"."telefone"::varchar ILIKE '%5332733535%'
        AND "Home"."ativo" = 'TRUE'
        AND "Home"."status_id_destino"
             IN (1, 2, 3, 4, 5, 6, 7, 8, 9)
 ORDER BY "Ose"."id" asc LIMIT 20

Giving CASTING before ILIKE or as per the CPF or CNPJ field type in the VARCHAR or INT? database provided by rray , the best option would be to change the type of field telefone to varchar .

    
28.12.2016 / 13:40