Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Impossible to insert a Double.NaN value #217

Copy link
Copy link
@Tradioyes

Description

@Tradioyes
Issue body actions

This is a regression from 2.0.13-beta1.
I tried to upgrade to 2.1.3 and Npgsql crashed when I try to insert a NaN value in a double precision field.
The error is:
Npgsql.NpgsqlException : ERROR: 42703: column "nan" does not exist

The first tests works, the second raises the error.

    [Test]
    public void HandleDoubleValueParameter()
    {
        ExecuteNonQuery(@"CREATE TABLE dataDouble (
                            field_double                  double precision
                            )");
        try
        {
            var command = new NpgsqlCommand("insert into dataDouble(field_double) values (:a)", Conn);
            command.Parameters.Add(new NpgsqlParameter("a", NpgsqlDbType.Double));
            command.Parameters[0].Value = 123.456;
            var query = command.CommandText;
            var rowsAdded = command.ExecuteNonQuery();
            Assert.AreEqual(1, rowsAdded);
        }
        finally
        {
            ExecuteNonQuery(@"DROP TABLE dataDouble");
        }
    }

    [Test]
    public void HandleDoubleNanValueParameter()
    {
        ExecuteNonQuery(@"CREATE TABLE dataDouble (
                            field_double                  double precision
                            )");

        try
        {
            var command = new NpgsqlCommand("insert into dataDouble(field_double) values (:a)", Conn);
            command.Parameters.Add(new NpgsqlParameter("a", NpgsqlDbType.Double));
            command.Parameters[0].Value = double.NaN;
            var query = command.CommandText;
            var rowsAdded = command.ExecuteNonQuery();
            Assert.AreEqual(1, rowsAdded);
        }
        finally
        {
            ExecuteNonQuery(@"DROP TABLE dataDouble");
        }
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.