SCM

[#1010979] FormatException when reading array

View Trackers | Bugs | Download .csv | Monitor

Date:
2011-01-25 08:12
Priority:
3
State:
Open
Submitted by:
Peter Paulovic (mrjoe)
Assigned to:
Nobody (None)
Npgsql Version:
None
Category:
Group:
Resolution:
None
Summary:
FormatException when reading array

Detailed description
I have column with integer[] array data type. If array contains numbers everything works fine. But if I insert NULL value into an array I get FormatException when I call DataReader GetValue.

Problem is in NpgsqlBackendTypeInfo.ConvertToNative() at line 862

---
return Convert.ChangeType(BackendData, Type, CultureInfo.InvariantCulture);
---

Where conversion to Int32 fails because BackendData == "NULL".

Followup

Message
Date: 2011-02-08 23:13
Sender: Gildas

I can't reproduce the problem, so :
- whats the version you're using ?
- can you post some code to reproduce the problem for sure ?

Below is the code that I use to reproduce the problem :
// insert null
NpgsqlCommand command = new NpgsqlCommand("insert into erroronintegerarray(tabeauint) values(:tabeauint)", con);
NpgsqlParameter param = new NpgsqlParameter(":tabeauint", NpgsqlDbType.Array | NpgsqlDbType.Integer);
param.Value = null;
command.Parameters.Add(param);
command.ExecuteNonQuery();

// select it
command = new NpgsqlCommand("select tabeauint from erroronintegerarray LIMIT 1;", con);
object result = command.ExecuteScalar();
int[] intArray;
if (!(result is System.DBNull))
{
intArray = (int[])result;
}

Thanks

Attached Files:

Changes:

No Changes Have Been Made to This Item

Powered By FusionForge