JordanMarr / SqlHydra

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

Types for views are not generated #16

Closed MargaretKrutikova closed 2 years ago

MargaretKrutikova commented 2 years ago

We are using a postgres database and it seems like sqlhydra doesn't generate types for views. Is there anything extra we need to add in the configuration file? Or is it not supported by the library?

Thanks!

JordanMarr commented 2 years ago

That is not by design. I’m guessing that the metadata query is not returning info on views.

MargaretKrutikova commented 2 years ago

Here it seems like we are fetching tables and columns, but not views, right? https://github.com/JordanMarr/SqlHydra/blob/main/src/SqlHydra.Npgsql/NpgsqlSchemaProvider.fs#L10 Could it be the case that we are just not even fetching views? 🙂

In NpgsqlSchema in npgsql they do fetch views separately.

MargaretKrutikova commented 2 years ago

Okay, I understand what you meant. Seems like let sTables = conn.GetSchema("Tables") doesn't include views, but conn.GetSchema("Views") will return views on the other hand. However, for views the resulting dataset doesn't have TABLE_TYPE. Do you think we can fetch views separately and concatenate them with tables while removing TABLE_TYPE (since we will know which one comes from tables or views)?

JordanMarr commented 2 years ago

Oh that’s perfect! Yes we can pull the views separately and then manually set the table type.