Zaid-Ajaj/Npgsql.FSharp

Npgsql while creating Tables

funkr opened this issue · 2 comments

funkr commented

Hallo Zaid,

I see Npgsql terribly crashing:

Npgsql.NpgsqlException (0x80004005): Received backend message ParseComplete while expecting ReadyForQueryMessage. Please file a bug.
at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
at Npgsql.NpgsqlCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
at Dapper.SqlMapper.QueryRowAsync[T](IDbConnection cnn, Row row, Type effectiveType, CommandDefinition command) in C:\projects\dapper\Dapper\SqlMapper.Async.cs:line 451

I get this while I am running Expecto Test.

This is my connection

let private connectionFPG () =
        let path = "host=localhost;port=5432;Uid=postgres;Password=password;Database=postgres"
        SqlServerConnection (new NpgsqlConnection (path))

This is my async call:

let querySingleAsync<'R> = querySingleOptionAsync<'R> (connectionFPG)

This is my crashing call:

let CreateTablesPG () =
        Queries.querySingleAsync<int> {
            script """
                CREATE TABLE customary_recess
                (
                    cr_date        DATE,
                    cr_country     TEXT,
                    cr_description TEXT
                );

What I understood from the documentations that I should get an integer return value, but giving no type does the same.
With SQLite is the construct working.

What do I wrong here? Or is this a bug as the error message says?

Hi there @funkr, I am not sure I understand the code above. I see the function querySingleOptionAsync<'R> but this function is nowhere defined in this library.

Regardless of the library, I see you are using NpgsqlConnection as input to SqlServerConnection which might give funny results because these are two different database server types, why not just this

let private connectionFPG () =
        let path = "host=localhost;port=5432;Uid=postgres;Password=password;Database=postgres"
        new NpgsqlConnection (path)
funkr commented

I checked it and you are right. We can close that.