Releases: JordanMarr/SqlHydra
v2.8.0
SqlHydra.Query v2.8.0
☀️.NET 9 Support (thanks, @EverybodyKurts!)
☀️Added support for SQL Server output
in insert and update builders which allows you to return one or more inserted columns.
open SqlHydra.Query
open SqlHydra.Query.SqlServerExtensions
let insertPerson (row: Person) =
task {
let! createDate, updateDate =
insertTask openContext {
for p in dbo.Person do
entity row
output (e.CreateDate, e.UpdateDate)
}
return updateDate
}
open SqlHydra.Query
open SqlHydra.Query.SqlServerExtensions
let updateRaceway (req: SaveRequest) =
updateAsync openContext {
for rw in dbo.RACEWAYS do
set rw.DRAWING_AREA req.DrawingArea
set rw.UPDATED_DATE DateTime.Now
where (rw.JOB_ID = jobId && req.RUN_NUMBER = runNo)
output rw.UPDATED_DATE
}
SqlHydra.Cli v2.8.1
☀️.NET 9 Support (thanks, @EverybodyKurts!)
☀️Fixed so that SQL Server HierarchyId
column (added in v2.7.0) is not added to the generated primitive types function unless HierarchyId
is actually used in the generated schema (since it requires an extra NuGet package).
v2.7.0
SqlHydra.Cli v2.7.0
😺 SQL Server generation now supports HierarchyId
column type. (Thanks to @michelbieleveld for contributing this feature!)
SqlHydra.Query v2.7.0
😺 Add new areEqual
and notEqual
query functions to support querying against the HierarchyId
column type.
It is necessary to use these functions since the HierarchyId
type overloads the =
operator to return a SqlBoolean
instead of a bool
, which breaks the query syntax.
Usage example:
let node = child.GetAncestor(1)
let! result =
selectTask ctx {
for row in ext.HierarchyIdSupport do
where (row.Id = id_parent && areEqual row.Hierarchy node)
select row.Hierarchy
toList
}
v2.6.0
SqlHydra.Cli v2.6.0
😺 Generating types for a netstandard
project will now automatically generate "legacy mode" DateTime
and TimeSpan
instead of using DateOnly
and TimeOnly
types.
😺 New selectTask
and selectAsync
computation expressions are now generated to work with your generated HydraReader.Read
and table types.
Previously, you had to manually pass in the generated HydraReader.Read
method to your selectTask
and selectAsync
builders:
open SqlHydra.Query
open AdventureWorks.Generated
let getErrorNumbers () =
selectTask HydraReader.Read openContext {
for e in dbo.ErrorLog do
select e.ErrorNumber
}
Now, you can use the generated versions which have the HydraReader.Read
method baked-in:
open SqlHydra.Query
open AdventureWorks.Generated
open AdventureWorks.Generated.HydraBuilders // Generated builders are here
let getErrorNumbers () =
selectTask openContext {
for e in dbo.ErrorLog do
select e.ErrorNumber
}
v2.5.3
v2.6.0-beta.1 - MySQL Beta Support
This beta release adds type generation support to SqlHydra.Cli for MySQL. (Thanks to @RJSonnenberg for the contribution!)
v2.5.0
SqlHydra.Query v2.5.0
- In a select query, specifying a table or tables using the
select
keyword now explicitly selects all the columns in the table record; previously, it would issue aselect tbl.*
query. It is now recommended to always explicitlyselect
a table. (If you do not explicitly select, it will generate aselect tbl.*
style query which will be less performant.)
Ex:
❌ This will issue a SELECT *
query which will result in a table scan which will result in slightly worse performance.
let! results =
selectTask' openContext {
for p in Person.Person do
take 10
}
✅ This will explicity select all columns in the Person
table, which will result in slightly better performance.
let! results =
selectTask' openContext {
for p in Person.Person do
take 10
select p
}
SqlHydra.Cli v2.5.0
- The generated
HydraReader
now filters out any columns that do not exist in the selected table record(s). (This fixes a bug that could happen when a column was added to a table and the types were not regenerated.
NOTE: You must upgrade both SqlHydra.Query and SqlHydra.Cli at the same time to v2.5.x.
v2.4.1
SqlHydra.Query
- Added implicit conversions to
ContextType
.
The ContextType
(Shared
, Create
, CreateAsync
and CreateTask
) is now implicitly converted.
This allows you to either pass in a QueryContext
or a function that returns a QueryContext
to your selectTask
and selectAsync
expressions. This is a huge quality-of-life improvement, IMO!
See Select Builders in readme for more examples.
Old:
let getErrorNumbers () =
selectAsync HydraReader.Read (Create openContext) {
for e in dbo.ErrorLog do
select e.ErrorNumber
}
Becomes:
let getErrorNumbers () =
selectAsync HydraReader.Read openContext {
for e in dbo.ErrorLog do
select e.ErrorNumber
}
Old:
let getErrorNumbers (ctx: QueryContext) =
selectAsync HydraReader.Read (Shared ctx) {
for e in dbo.ErrorLog do
select e.ErrorNumber
}
Becomes:
let getErrorNumbers (ctx: QueryContext) =
selectAsync HydraReader.Read ctx {
for e in dbo.ErrorLog do
select e.ErrorNumber
}
If you create a shortcut select CE that embeds the generated HydraReader.Read
function, it becomes even more succinct:
let selectTask' ct = selectTask HydraReader.Read ct
let distinctCustomerNames (ctx: QueryContext) =
selectTask' ctx {
for c in SalesLT.Customer do
select (c.FirstName, c.LastName)
distinct
}
v2.4.0
SqlHydra.Cli
-
Rewrote code generation using Fabulous.AST!
-
Added new
mutable_properties
option to toml which makes all record properties mutable. 🙀 (defaults to false.) -
Added new
nullable_property_type
option to toml which allows nullable columns to be generated as either F#option
types (default) orSystem.Nullable
properties. The latter can be useful for C# interop or CRUD scenarios where you want to data bind generated types directly to UI controls. (Generally, I would recommend mapping generated types to domain entities or DTOs, but it's nice to have the option to do things in a quick and dirty way.)mutable_properties = true
nullable_property_type = "Nullable"
-
Improved CLI Output
- The entire TOML configuration is now printed to CLI
- TOM include/exclude filters are now printed to CLI, along with the number of tables generated (post-filter) and the total number of tables found (pre-filter) to the console. #88
-
All providers will now ignore any tables / views with no columns (just in case)
-
Postgres
"time with time zone"
columns now generate DateTimeOffset properties -
Postgres now generates materialized views (requires net8 and npgsql v8 or greater). #84
-
Updated CLI to latest
"Microsoft.Data.SqlClient"
to fix warnings
SqlHydra.Query
-
Changes to support the new
System.Nullable
column/properties in the Linq query syntax -
Changes to support the new
System.Nullable
column/properties query parameters -
Adds
CreateTask
andCreateAsync
cases to theContextType
discriminated union. #89 -
Exposed
KataQuery
property on all queries (the resulting type of query builders) to make it possible to manipulate the underlying SqlKata query for inserts, updates and selects before executing the query. -
Added
head
custom operation to theSelectBuilder
for queries where you know there should always be at least one result. (Before you had to usetryHead
, and then manually extract the value.)
v2.4.0-beta.6
SqlHydra.Query
- Adds
CreateTask
andCreateAsync
cases to theContextType
discriminated union.
SqlHydra.Cli
- Updates to the latest version of Fabulous.AST for code generation
v2.4.0-beta.5
SqlHydra.Cli
- Now prints the active filters, number of tables generated (post-filter) and the total number of tables found (pre-filter) to the console. #88
SqlHydra.Query
- No changes.