JordanMarr / SqlHydra

SqlHydra is a suite of NuGet packages for working with databases in F# including code generation tools and query expressions.
MIT License
212 stars 21 forks source link

`SqlHydra.ProviderDbType` Attribute requires SqlHydra.Query #42

Closed JordanMarr closed 1 year ago

JordanMarr commented 1 year ago

Issue

(Raised by @isaacabraham)

Table records generated by SqlHydra may contain SqlHydra.ProviderDbType attributes. This attribute is declared in the SqlHydra.Query package and is added to generated types to designate database specific parameter types for SqlHydra.Query to use when creating query parameters.

Proposed Solution

Add a new configuration option, provider_db_type_attributes, to the .toml config file under the [sqlhydra_query_integration] section to allow users to exclude the [<ProviderDbType>] attributes used by SqlHydra.Query. (This will default to true if not present.)

Ex:

[general]
connection = "Server=localhost,12019;Database=AdventureWorks;User=sa;Password=Password#123;TrustServerCertificate=True"
output = "SqlServer/AdventureWorksNet5.fs"
namespace = "SqlServer.AdventureWorksNet5"
cli_mutable = true
[sqlhydra_query_integration]
provider_db_type_attributes = false
[readers]
reader_type = "Microsoft.Data.SqlClient.SqlDataReader"
[filters]
include = [ "*" ]
exclude = [ "*/v*" ]
JordanMarr commented 1 year ago

@isaacabraham:

SqlHydra.* v1.1.1 has just been published to fix this issue. The CLI first-time run wizard has been greatly simplified:

After getting the required fields (connection string, filename, namespace), it now only asks you to "Select a use case:" with the following options:

It then sets all the configuration defaults accordingly (instead of asking you a bunch of random questions). The second and third options will not generate the SqlHydra.Query specific attributes.

You fix your config by either: