Closed MangelMaxime closed 1 year ago
Ok, I think that should be a simple fix.
In case it helps here is the configuration file I am using:
[general]
connection = "Server=127.0.0.1,33300;Database=XXX;User Id=SA;Password=XXXXXXXX;TrustServerCertificate=True"
output = "Server/Antidote.Database/Dbos.fs"
namespace = "Antidote.Database"
cli_mutable = false
[readers]
reader_type = "Microsoft.Data.SqlClient.SqlDataReader"
[filters]
include = []
exclude = []
With sqlhydra.sqlserver@1.1.1
It seems to be caused by using the _
assignment. My first attempt to recreate it, I assigned it to an actual binding/variable and it works:
for e in Tables.encounterForms do
deleteAll
For deletes, I think your usage of _
makes sense when deleting all rows in a table, and so I am fixing this bug now.
For updates and inserts, I think I will throw a _ is unsupported
exception since a type is required in order to get ProviderDbType column attributes.
For selects, it does not apply because it is not possible to use an underscore anyway as there is no selectAll
keyword. (You would have to do select p
for that.) Plus, it is required to assign to a projection binding anyway for selects.
A fix has been pushed to the main branch that allows _
to be used only for DeleteBuilder
queries.
Thank you @JordanMarr
I never tough it would be because of the _
😅.
I will test it when released.
Previous versions always created queries using the fully qualified table and column names, but a recent update changed it so that everything uses table aliases named after the actual table binding.
For example, this query:
for p in dbo.Tables.Products do
select p
will now use p
as the table alias:
SELECT p.*
FROM dbo.Products AS p
This change makes the generated queries nicer, but more importantly, it allows for same table joins. So that's what caused the odd bug!
SqlHydra.Query v1.1.1 is now released with the patch.
The alias makes senses.
Fix is also working for my project thank you very much.
Using the following code with SqlHydra.Query 1.1.0 result in an error at runtime:
Downgrading to SqlHydra 1.0.5 with the following code:
works.