-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facil generator fails when stored procedure contains merge statement (odd issue) #39
Comments
Thanks for the detailed report and minimal repro, I'll try to have a look at it during the weekend or next week. |
Thank you!! |
Fix published in v2.5.5.
The bug was that it did not create the temp table the second time (on the second connection). Opening two connections and executing the sproc twice is as designed. In order to get the result set metadata, Facil tries the following in succession (stopping at whatever works):
If step 3 is needed, it is performed on a separate connection/transaction (which is rolled back) to ensure there are no changes to the database. The bug was that the creation of the temp tables was not performed in step 3, so if a stored procedure (or script) needed this approach and used temp tables, they would fail with the error you encountered. |
Hi, thinking more, just an idea. It would be best for step 3 if you can allow the users of the library to specify the test sql statement in the configuration yaml file. The reason for this is that providing some parameter random value can lead to an execution branch that raises an exception, especially if the code in the procedure takes a defensive approach and checks thoroughly the parameter values to make sure they comply with expected values. The developer or the owner of the procedure know exactly what the procedure does and can provide parameter values that will return the expected runtime structure (the happy path). What do you think? I know it is more work, but it makes your library sturdier. Thanks |
I will create a separate request. |
Feel free, but I am unlikely to add it (was writing a response here, will wait for the separate issue instead), so don't spend too much time on it. |
Hi,
I spent at least 2 hours on this one.
What do I want to do? I want to generate the code that calls a stored procedure that processes data that is shoved in a sql server temp table.
Here are the files that can help you reproduce the issue:
TempTable1.sql:
This file goes under some directory containing sql (I put it under a folder called CreateTable).
in the yaml I have under procedures:
Here is the stored procedure code:
When I build the project I get these errors:
I was curious and I used the sql server profiler to check what facil executes and it looks like facil executes
exec dbo.spTestFacil @psParam=N'1'
twice for whatever reason, but before it runs the second time it creates a new connection and it does not create the temp tables.It's very odd. Any idea?
For now, to move on, I am going to comment out the bodies of the stored procedures, run the generator, and them add them back. It is a pain but it works.
Thanks
Update: I forgot to include the usual info: .net 6.0, latest version of facil as of today (2.5.4), windows 2016 server. I use rider.net 2022.1.2, sql server 2017.
The text was updated successfully, but these errors were encountered: