demetrixbio / FSharp.Data.Npgsql

F# type providers to support statically typed access to input parameters and result set of sql statement in idiomatic F# way. Data modifications via statically typed tables.
Apache License 2.0
127 stars 16 forks source link

PostgisGeometry error after upgrading to 0.1.35 beta #23

Closed sandeepc24 closed 6 years ago

sandeepc24 commented 6 years ago

I am getting following error after upgrading to 0.1.35 beta. I am on dotnet 2.1.4.

 error FS3021: Unexpected exception from provided type 'FSharp.Data.Npgsql.NpgsqlConnection,Connection="DATABASE_URL_PG",Config="C:\\.../appsettings.json"+Commands+CreateCommand,CommandText"select * from addresses where id  AddressId",ResultType"2"+Table' member 'GetMethods': The type provider 'FSharp.Data.Npgsql.NpgsqlProviders' reported an error: The design-time type 'Npgsql.LegacyPostgis.PostgisGeometry' utilized by a type provider was not found in the target reference assembly set...
dmitry-a-morozov commented 6 years ago

Thanks for reporting the issue. It's bit hard to test. Try https://www.nuget.org/packages/FSharp.Data.Npgsql/0.1.36-beta

sandeepc24 commented 6 years ago

Thanks for fixing it Dmitry, I have an urgent issue to fix before I can test this, I'll let you know once I test this version.

sandeepc24 commented 6 years ago

Apologies for the delayed response. It is still not working and I am getting same error.

dmitry-a-morozov commented 6 years ago

Make sure you reference Npgsql.LegacyPostgis package in consumption project.

sandeepc24 commented 6 years ago

It is working fine after adding this package. Thanks a lot Dmitry.

dmitry-a-morozov commented 6 years ago

Great. Just curios how did you end up missing Npgsql.LegacyPostgis package? Because it's listed as explicit dependency https://www.nuget.org/packages/FSharp.Data.Npgsql/0.1.36-beta

Also, going forward some re-design will required to support choice between

sandeepc24 commented 6 years ago

Npgsql.LegacyPostgis was never installed and it didn't install when I upgraded to 0.1.36.

dmitry-a-morozov commented 6 years ago

It's strange because Npgsql.LegacyPostgis is transitive dependency and it has to be there

image

sandeepc24 commented 6 years ago

My project compiles after adding package Npgsql.LegacyPostgis to my paket.reference but I am getting following error

An unhandled exception has occurred while executing the request.
  System.InvalidOperationException: Expected column "geom" of type "Npgsql.LegacyPostgis.PostgisGeometry" at position 6 (0-based indexing) but received column "geom" of type "System.String".
     at FSharp.Data.Npgsql.ISqlCommand Implementation.VerifyOutputColumns(NpgsqlDataReader cursor, DataColumn[] expectedColumns)
dmitry-a-morozov commented 6 years ago

You need to add type mappers https://github.com/demetrixbio/FSharp.Data.Npgsql/blob/master/tests/NpgsqlCmdTests.fs#L19

I realized that library should do it automatically when connection string passed into command ctor.

sandeepc24 commented 6 years ago

Do you monitor FSharp slack or FSharp forums?

dmitry-a-morozov commented 6 years ago

no

sandeepc24 commented 6 years ago

Thanks that fixed it.

sandeepc24 commented 6 years ago

oops that fixed compilation only, I am still getting

 Expected column "geom" of type "Npgsql.LegacyPostgis.PostgisGeometry" at position 6 (0-based indexing) but received column "geom" of type "System.String".
     at FSharp.Data.Npgsql.ISqlCommand Implementation.VerifyOutputColumns(NpgsqlDataReader cursor, DataColumn[] expectedColumns)
dmitry-a-morozov commented 6 years ago

Do you pass connection string or connection instance to a command that fails?

sandeepc24 commented 6 years ago

connection string

dmitry-a-morozov commented 6 years ago

I need to post a fix to make it work.

sandeepc24 commented 6 years ago

ok, I'll wait for your fix. Thanks.

dmitry-a-morozov commented 6 years ago

Try https://www.nuget.org/packages/FSharp.Data.Npgsql/0.1.38-beta

sandeepc24 commented 6 years ago

Thanks, that fixed the issue.