SCM

[#1011341] Prepared INSERT statement with array parameter stores wrong value

View Trackers | Bugs | Download .csv | Monitor

Date:
2013-06-19 07:11
Priority:
3
State:
Closed
Submitted by:
Juergen Steiner (steinerj)
Assigned to:
Shay Rojansky (roji)
Npgsql Version:
2.0.12beta
Category:
None
Group:
None
Resolution:
None
Summary:
Prepared INSERT statement with array parameter stores wrong value

Detailed description
Version is 2.0.12.0, not beta, but couldn't select this from the version drop-down.

I've got a table containing an integer array:

CREATE TABLE array_test
(
id integer NOT NULL DEFAULT nextval('"ArrayTest_ID_seq"'::regclass),
int_array integer[] NOT NULL,
CONSTRAINT array_test_pkey PRIMARY KEY (id)
)
WITH (
OIDS=FALSE
);

and some C# code where I insert a row into this table:

NpgsqlCommand insertArray = new NpgsqlCommand("INSERT INTO array_test (int_array) VALUES (:array_values)", this.connection);
insertArray.Parameters.Add(new NpgsqlParameter("array_values", NpgsqlDbType.Array | NpgsqlDbType.Integer));
insertArray.Parameters["array_values"].Value = new int[] { 1, 2, 3, 4, 5 };
insertArray.ExecuteNonQuery();

which works fine and stores a row like that:
1 | {1, 2, 3, 4, 5}

When I prepare the command before using it:

NpgsqlCommand insertArray = new NpgsqlCommand("INSERT INTO array_test (int_array) VALUES (:array_values)", this.connection);
insertArray.Parameters.Add(new NpgsqlParameter("array_values", NpgsqlDbType.Array | NpgsqlDbType.Integer));
insertArray.Prepare();
insertArray.Parameters["array_values"].Value = new int[] { 1, 2, 3, 4, 5 };
insertArray.ExecuteNonQuery();

the array is stored as a two-dimensional array instead:
2 | {{1, 2, 3, 4, 5}}

Followup

Message
Date: 2014-01-07 10:22
Sender: Shay Rojansky

Great.

It's probably a matter of 2-3 weeks, keep posted.

In the meanwhile you can definitely run on 2.1.0-beta1 - we think it's relatively stable and would appreciate any bug reports on it too.
Date: 2014-01-07 09:37
Sender: Juergen Steiner

I've tested on 2.1.0-beta1 and can confirm that the problem has been solved in that version, thanks!

Any idea when 2.1.0 will be released?
Date: 2013-12-29 23:18
Sender: Shay Rojansky

We've released 2.1.0-beta1, where this bug no longer seems reproducible. Can you please test on this version and confirm?
Date: 2013-12-17 09:31
Sender: Shay Rojansky

Migrated to github, please watch it there: https://github.com/npgsql/Npgsql/issues/130
Date: 2013-12-16 09:37
Sender: Juergen Steiner

I've tested it with 2.0.14.2, and the bug is still there, same results as before
Date: 2013-12-12 22:57
Sender: Shay Rojansky

This bug seems to have been fixed, can you please try the newly-released 2.0.14 and confirm?

Attached Files:

Changes:

Field Old Value Date By
status_idOpen2013-12-17 09:31roji
close_dateNone2013-12-17 09:31roji
assigned_tonone2013-09-30 22:31roji
Powered By FusionForge