sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

MATCH AGAINST not working in MYSQL

Open raymondgitonga opened this issue 4 years ago • 3 comments

Version

1.9.0

What happened?

Playground

Code generated doesn't include function parameters for against field.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

MySQL

What type of code are you generating?

Go

raymondgitonga avatar Sep 17 '21 13:09 raymondgitonga

The playground link you posted isn't working. Can you include the SQL and JSON here in the issue?

kyleconroy avatar Sep 17 '21 15:09 kyleconroy

select produto_sku, produto_nome, 'P' as tipo, familia_id, ifnull(produto_tipo,'') as produto_tipo, categoria_title, 
                                categoria_id, sub_categoria_nome, indicado_descricao, indicado_id, categoria_nome, 
                                match(produto_termo_chave) against("dipirona") as vl_match , 
                                if(match(produto_termo_chave) against("dipirona" IN BOOLEAN MODE) > 0, 1,
                                 if(match(produto_principio_ativo) against("dipirona" IN BOOLEAN MODE) > 0, 3, 
                                  if(match(indicado_descricao) against("dipirona" IN BOOLEAN MODE) > 0, 4, 
                                   if(match(sub_categoria_nome) against("dipirona" IN BOOLEAN MODE) > 0, 5, 6)))) as tipo_resultado, 
                                 produto_qtde_ofertas, if(ifnull(produto_qtde_ofertas,0) = 0, 'N', 'S') as disponibilidade
                            from tbl_produto_autocomplete
                            where (match(produto_termo_chave) against("dipirona" IN BOOLEAN MODE))
                             or (match(sub_categoria_nome) against("dipirona" IN BOOLEAN MODE)) 
                             or (match(produto_principio_ativo) against("dipirona" IN BOOLEAN MODE)) 
                             or (match(indicado_descricao) against("dipirona" IN BOOLEAN MODE)) 
                            order by categoria_id, disponibilidade desc, tipo_resultado, produto_qtde_ofertas desc,  produto_nome;

@kyleconroy this query is a good example. sqlc cannot generate it and throws an exception near > 0,1.

diasjuniorr avatar May 23 '22 08:05 diasjuniorr

Just for some additional context / example here, here's a simple playground link. Been trying sqlc.arg w/ no success. Any ideas here for a workaround?

morgangallant avatar Sep 07 '22 15:09 morgangallant

Encountered the same issue. sqlc seems to ignore parameter inside a match against(?) clause

hackthehackerman avatar Nov 05 '22 22:11 hackthehackerman