You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add possibility to fake function with temp or derived tables (#53)
* Add possibility to fake function with temp or derived tables
* Remove wrongly removed new lines
* PR#53 Add new lines at the end of the files
* PR#53 Add missing schema for the table
* Remove test
* PR#53 Fix tests
* Change naming convention for the FakeFunction data output table name
* Fix issue with the long function names
* Add FakeFunction test for long name and output table schema
* Add test for data source table starting with SELECT
* Using tSQLt.Private::CreateUniqueObjectName() to generate random object name
* Remove `FunctionName` parameter
* Change build order as CLR is used
* Fix fake functions test
* Add CLR function exception message test
* Remove CONCAT usage
* Add CLR TVF support
Copy file name to clipboardExpand all lines: Source/tSQLt.Private_CreateFakeFunction.ssp.sql
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -3,11 +3,12 @@ GO
3
3
---Build+
4
4
GO
5
5
CREATEPROCEDUREtSQLt.Private_CreateFakeFunction
6
-
@FunctionName NVARCHAR(MAX),
7
-
@FakeFunctionName NVARCHAR(MAX),
8
-
@FunctionObjectId INT,
9
-
@FakeFunctionObjectId INT,
10
-
@IsScalarFunction BIT
6
+
@FunctionName NVARCHAR(MAX),
7
+
@FakeFunctionName NVARCHAR(MAX) =NULL,
8
+
@FunctionObjectId INT=NULL,
9
+
@FakeFunctionObjectId INT=NULL,
10
+
@IsScalarFunction BIT=NULL,
11
+
@FakeDataSource NVARCHAR(MAX) =NULL
11
12
AS
12
13
BEGIN
13
14
DECLARE @ReturnType NVARCHAR(MAX);
@@ -44,6 +45,12 @@ BEGIN
44
45
BEGIN
45
46
EXEC('CREATE FUNCTION '+@FunctionName+'('+@ParameterList+') RETURNS '+@ReturnType+' AS BEGIN RETURN '+@FakeFunctionName+'('+@ParameterCallList+');END;');
CREATE PROCEDURE FakeFunctionTests.[test errors when both @FakeFunctionName and @FakeDataSource are passed]
426
+
AS
427
+
BEGIN
428
+
EXEC('CREATE FUNCTION FakeFunctionTests.AFunction(@a int, @b int) RETURNS TABLE AS RETURN (SELECT @a AS one);');
429
+
EXEC tSQLt.ExpectException @ExpectedMessage ='Both @FakeFunctionName and @FakeDataSource are valued. Please use only one.', @ExpectedSeverity =16, @ExpectedState =10;
CREATE PROCEDURE FakeFunctionTests.[test errors when neither @FakeFunctionName nor @FakeDataSource are passed]
434
+
AS
435
+
BEGIN
436
+
EXEC('CREATE FUNCTION FakeFunctionTests.AFunction(@a int, @b int) RETURNS TABLE AS RETURN (SELECT @a AS one);');
437
+
EXEC tSQLt.ExpectException @ExpectedMessage ='Either @FakeFunctionName or @FakeDataSource must be provided', @ExpectedSeverity =16, @ExpectedState =10;
0 commit comments