Page 1 of 1

The behavior of PgSqlArray is different if UnpreparedExecute = False.

Posted: Tue 05 Nov 2019 14:09
by Valéry Fourmi
The behavior of PgSqlArray is different if UnpreparedExecute = False.

code snippet:

Code: Select all

var databaseParameter = new Devart.Data.PostgreSql.PgSqlParameter(
                            ":p0_0",
                            new Devart.Data.PostgreSql.PgSqlArray(new string[]{"\"avec quotes\"", "titi"}, Devart.Data.PostgreSql.PgSqlType.VarChar,  1, 2));
var parameters = new List<PgSqlParameter>(){databaseParameter };
var commandText = "SELECT x, y from Mytable WHERE (metadata ->> 'FME_EPRPROJ07_Str_Code') ilike ANY(:p0_0 ::varchar[]) ) ";
this.context.Database.SqlQuery<myObject>(commandText , parameters );
This code works when the connection string has UnpreparedExecute = False,
but fails when UnpreparedExecute = True with the following error: {"malformed array:" {\ "\\\\\" avec quotes\\\\\ "\", titi} ""}

NB: databaseParameter.pgSqlValue is

Code: Select all

{{"\"avec quotes\"",titi}}
in both cases.

Thanks for your helps.

Re: The behavior of PgSqlArray is different if UnpreparedExecute = False.

Posted: Fri 08 Nov 2019 08:25
by Valéry Fourmi
This is resolved when I add explicitly the type of parameter:

I added after the follow line

Code: Select all

databaseParameter.dbType = databaseParameter.DbType = System.Data.DbType.AnsiString;
by default the databaseParameter.dbType was System.Data.DbType.String;

I don't know why, but it works.

Re: The behavior of PgSqlArray is different if UnpreparedExecute = False.

Posted: Mon 11 Nov 2019 21:04
by Shalex
Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Re: The behavior of PgSqlArray is different if UnpreparedExecute = False.

Posted: Thu 21 Nov 2019 17:54
by Shalex
The bug with using PgSqlArray of the Varchar type as a command parameter, when connection string includes "UnpreparedExecute=True;", is fixed: viewtopic.php?f=3&t=39574.