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
128 stars 15 forks source link

Postgis parameters on Sql statement fails #84

Closed Swoorup closed 4 years ago

Swoorup commented 4 years ago

It appears that the type provider fails to recognize parameters as a postgis type and isn't able to correctly deduce the correct CLR type.

NpgsqlCommand<"SELECT ST_DWithin(@points, ST_GeomFromText('POINT(-12.5842 24.4944)',4326), 1)", dvdRental, SingleRow = true>(conn)

The type provider fails on the above query when the parameter is of postgis type with the error message:

error FS3033: The type provider 'FSharp.Data.Npgsql.NpgsqlProviders' reported an error: Could not find PostgreSQL type public.geometry

Once I temporarily fix the error with a global registration of Npgsql.NetTopologySuite mapping I get a different error message:

The type provider 'FSharp.Data.Npgsql.NpgsqlProviders' reported an error: The given key was not present in the dictionary.

Firstly there probably needs to be a global parameter specifying if to use NetTopologySuite Npgsql mappings. But I am not sure about the second problem. Any ideas how to approach this?

kerams commented 4 years ago

You can try debugging the design time part to see where the exception originates https://github.com/demetrixbio/FSharp.Data.Npgsql/issues/76#issuecomment-602021760

Swoorup commented 4 years ago

Found the bug, and fixed it :dancing_men:

melanore commented 4 years ago

Thank you, @Swoorup!