On 29-03-2023 17:46, Alan Braga wrote:
> Hi.
>
> I'm having trouble with where clause using accents, the following Linq
> command:
>
> *contexto.Set<CondicaoFornecimento>()*
> * .Where(c => c.Descricao.Contains("tensão"));*
>
> Generate this SQL
>
> *SELECT "c"."Id", "c"."Codigo", "c"."Descricao"
> FROM "CondicoesFornecimento" AS "c"
> WHERE (POSITION(CAST(_UTF8'tensão' AS VARCHAR(6) CHARACTER SET UTF8),
> "c"."Descricao") > 0)*
>
> And the error "*Dynamic SQL Error *
> *SQL error code = -104 *
> *Malformed string*"
As far as I'm aware, this means your connection character set is not
UTF8 but something else. The character set introducer leads to the bytes
of the string literal to be interpreted as UTF8, but the byte of
character ã in ISO-8859-1 (0xE3) is not a valid first byte in UTF-8.
> If I remove the _UTF8, like that:
>
> *SELECT "c"."Id", "c"."Codigo", "c"."Descricao"
> FROM "CondicoesFornecimento" AS "c"
> WHERE (POSITION(CAST('tensão' AS VARCHAR(6) CHARACTER SET UTF8),
> "c"."Descricao") > 0)*
>
> It works fine.
More proof that the problem is with your connection character set. Using
connection character set UTF8 should fix that.
Mark
--
Mark Rotteveel