X Tutup
Skip to content

parameter parsing fails (regression) #296

@kobruleht

Description

@kobruleht

Newer npgsql versions does not parse :p parameters properly.
In 2.2.0-beta1 code below produces error

syntax error at or near ":"

shown in comment. npgsql sends :p6 to server without parsing it.

        using (var connection = new NpgsqlConnection(ConnectionString()))
        {
            connection.Open();
            DbCommand command = (DbCommand)connection.CreateCommand();
           command.CommandText = @"
 SELECT 1
 WHERE ''= 'type(''m.response'')#''O''%' AND :p6
            ";

           for (int i = 0; i < 7; i++)
           {
               IDbDataParameter param = command.CreateParameter();
               param.ParameterName = "p" + i.ToString();
               var value = DBNull.Value;
               command.Parameters.Add(param);
           }
           // syntax error at or near ":"
            command.ExecuteReader();
         }

    static string ConnectionString()
    {
        NpgsqlConnectionStringBuilder csb = new NpgsqlConnectionStringBuilder()
        {
            SearchPath = "public",
            Host = "localhost",
            Database = "postgres",
            UserName = "postgres",
            Password = "secret"
        };
        return csb.ConnectionString;
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    X Tutup