JasperFx / weasel

Database Development Made Easy for .Net
MIT License
65 stars 21 forks source link

Consistent generic support #129

Closed CptWesley closed 5 months ago

CptWesley commented 5 months ago

Resolves #128

Copy from issue:

Currenlty the implementation of GetDatabaseType and ToParameterType treat types with generics in different ways:

I would expect these two functions to treat generic types in the same way (otherwise it is always required to add 1 concrete and 1 open version to e.g. the NpgsqlTypeMapping implementation).

My proposal would be to first attempt to find a mapping for the type directly, if there is no such definition, retry on the open generic version of it.

jeremydmiller commented 5 months ago

@CptWesley The approach sounds fine to me. Can you add some tests for the new behavior though? Through PostgresqlDatabaseProvider/SqlServerDatabaseProvider.ToParameterType(Type type) maybe?

CptWesley commented 5 months ago

@jeremydmiller I added some tests, but it seems like the same tests for postgres are mostly failing for sqlserver. It appears that exceptions are thrown in different occassions. So I'm not sure how to handle that right now

jeremydmiller commented 5 months ago

@CptWesley I'm going to pull your PR in, and deal w/ whatever the test problems are. Got a couple other weasel fixes suddenly backlogged. Thanks for taking that on!