The behavior of PgSqlArray is different if UnpreparedExecute = False.

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for PostgreSQL
Post Reply
Valéry Fourmi
Posts: 2
Joined: Tue 05 Nov 2019 13:26

The behavior of PgSqlArray is different if UnpreparedExecute = False.

Post by Valéry Fourmi » Tue 05 Nov 2019 14:09

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.

Valéry Fourmi
Posts: 2
Joined: Tue 05 Nov 2019 13:26

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

Post by Valéry Fourmi » Fri 08 Nov 2019 08:25

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.

Shalex
Site Admin
Posts: 8926
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Mon 11 Nov 2019 21:04

Thank you for your report. We have reproduced the issue and are investigating it. We will notify you about the result.

Shalex
Site Admin
Posts: 8926
Joined: Thu 14 Aug 2008 12:44

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

Post by Shalex » Thu 21 Nov 2019 17:54

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.

Post Reply