Skip to content
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

ResultSetToTable Feature #19

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JonathanHallKJR
Copy link

This addresses the issue with testing stored procedures that contain an 'INSERT INTO EXEC' ( #18 )

Essentially my contribution is a drop in replacement for INSERT INTO #Actual EXEC tSQLt.ResultSetFilter [...] that uses CLR code to run as EXEC tSQLt.ResultSetToTable #Actual, [...]

I've a copied the ResultSetFilter test suite to ensure compatibility and added extra tests to prove my change works when the command being executed is a stored proc that nests its own 'INSERT INTO EXEC'

@lizbaron
Copy link
Contributor

@JonathanHallKJR , This looks like a great idea, but when we reviewed it, we didn't see any tests for the new code. If you are interested in pursuing this work, can you please add them?

Thanks!

@JonathanHallKJR
Copy link
Author

@lizbaron I wrote up this contribution almost 4 years ago and unfortunately no longer have a development environment to update and test changes anymore.

I'm happy for someone else to take it on to get this merged.

With respect to your comment regarding tests.

There were tests in GenerateTestsForResultsetToTableDataTypes.sql (based on GenerateTestsForResultsetFilterDataTypes.sql) to ensure the new code was close to a drop in replacement for tSQLt.ResultSetFilter

If you need a specific test to show it resolves the issue there is a replication of the issue associated in #18 that could be adapted to a standalone test by just updating this line:

@@ -28,3 +28,3 @@
 	CREATE TABLE #actual (col1 VARCHAR(15) NULL, col2 int NULL);
-	INSERT INTO #actual EXEC tSQLt.ResultSetFilter 1, 'EXEC ReplicateInsertExecIssue._DataUsesInsertExec';
+	EXEC tSQLt.ResultSetToTable #actual, 1, 'EXEC ReplicateInsertExecIssue._DataUsesInsertExec';

@ADEPTYS
Copy link

ADEPTYS commented Jun 2, 2021

Hi @lizbaron @JonathanHallKJR
Thank you for your awesome framework and great contribution. ResultSetToTable is must have feature because problem with testing procedure with internal EXEC INTO is very common. It would be great to have tools to deal with it. Please fix this problem.

@mattsmac
Copy link

mattsmac commented Jun 8, 2021

This issue is also causing a roadblock for me. If someone could review and merge, it would be a huge help!

@lizbaron
Copy link
Contributor

lizbaron commented Jun 9, 2021 via email

@mattsmac
Copy link

mattsmac commented Jun 9, 2021 via email

@@ -0,0 +1,85 @@
/*
Copyright 2011 tSQLt
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JonathanHallKJR , this all looks great. We'd like to make some small modifications, but critically, we can't use copyrighted code in an open-source framework. Are you ok with us deleting the copyright?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lizbaron

This file was largely copied from a file in the project, as such, I preserved the license agreement that was in place.

The original file can be found here /Experiments/GenerateTestsForResultsetFilterDataTypes.sql

@lizbaron
Copy link
Contributor

lizbaron commented Jun 14, 2021 via email

@@ -0,0 +1,150 @@
/*
* Copyright 2017 Jonathan Hall <[email protected]>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lizbaron, As I understand it that this is correct way to contribute code to an open source project?

The contribution uses the same license as tSQLt /Build/License.txt

[...] You may add Your own copyright statement to Your
modifications and may provide additional or different license terms and
conditions for use, reproduction, or distribution of Your modifications, or for
any such Derivative Works as a whole, provided Your use, reproduction, and
distribution of the Work otherwise complies with the conditions stated in this
License.

  1. Submission of Contributions. Unless You explicitly state otherwise, any
    Contribution intentionally submitted for inclusion in the Work by You to the
    Licensor shall be under the terms and conditions of this License, without any
    additional terms or conditions. Notwithstanding the above, nothing herein shall
    supersede or modify the terms of any separate license agreement you may have
    executed with Licensor regarding such Contributions.

@lizbaron
Copy link
Contributor

lizbaron commented Jun 17, 2021 via email

@lizbaron lizbaron mentioned this pull request Jun 17, 2021
@priyasomangali
Copy link

Hi @lizbaron @JonathanHallKJR thanks for keeping this PR going. Along with the synonyms issue( for which the workaround works atm) , this also seems to be a big blocker in adopting the framework as most of our SP are of that kind. Hope to get this published at the earliest

pguyot added a commit to pguyot/tSQLt that referenced this pull request Mar 30, 2023
The ResultSetInsert procedure works like ResultSetFilter but insert
results into a table which name is passed as third paramter,
`@Table`.

This works around the nested insert exec issue (tSQLt-org#18).
This is an alternative and original implementation of PR tSQLt-org#19.

Signed-off-by: Paul Guyot <[email protected]>
@maethes
Copy link

maethes commented Feb 6, 2024

Hi, any chance this PR or #192 will be merged?
Thanks, Matthias

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants