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

ResultSetFilter data type inconsistency #145

Open
mbt1 opened this issue Jan 10, 2022 · 3 comments
Open

ResultSetFilter data type inconsistency #145

mbt1 opened this issue Jan 10, 2022 · 3 comments
Labels

Comments

@mbt1
Copy link
Collaborator

mbt1 commented Jan 10, 2022

code to reproduce the issue:

EXEC tSQLt.NewTestClass xxxxx
GO
CREATE PROCEDURE xxxxx.testRShSV
AS
BEGIN
  CREATE TABLE xxxxx.xtwv(Id INT,sv SQL_VARIANT)
  INSERT xxxxx.xtwv(id,sv)VALUES(1,CAST(13 AS INT))
  INSERT xxxxx.xtwv(id,sv)VALUES(2,CAST('xx' AS VARCHAR(13)))
  INSERT xxxxx.xtwv(id,sv)VALUES(3,CAST('45' AS CHAR(2)))
  INSERT xxxxx.xtwv(id,sv)VALUES(4,CAST(NULL AS DECIMAL))
  
  SELECT *,SQL_VARIANT_PROPERTY(sv,'BaseType ') FROM xxxxx.xtwv;
  
  INSERT INTO xxxxx.xtwv
  EXEC tSQLt.ResultsetFilter 1, 'SELECT * FROM xxxxx.xtwv;';

  SELECT *,SQL_VARIANT_PROPERTY(sv,'BaseType ') FROM xxxxx.xtwv;

END
GO
EXEC tSQLt.Run xxxxx;
@mbt1 mbt1 added the bug label Jan 10, 2022
@clifton-collins3iii
Copy link

Is the following error related to this bug or a new bug?

Msg 6522, Level 16, State 1, Procedure tSQLt.ResultSetFilter, Line 0 [Batch Start Line 0]
A .NET Framework error occurred during execution of user-defined routine or aggregate "ResultSetFilter":
System.Data.SqlClient.SqlException: Implicit conversion from data type datetime to int is not allowed. Use the CONVERT function to run this query.
System.Data.SqlClient.SqlException:
at Microsoft.SqlServer.Server.SmiEventSink_Default.DispatchMessages(Boolean ignoreNonFatalMessages)
at Microsoft.SqlServer.Server.SqlPipe.SendResultsStart(SqlDataRecord record)
at tSQLtCLR.ResultSetFilter.sendResultsetRecords(SqlDataReader dataReader)
at tSQLtCLR.ResultSetFilter.sendSelectedResultSetToSqlContext(SqlInt32 resultsetNo, SqlString command)
at tSQLtCLR.StoredProcedures.ResultSetFilter(SqlInt32 resultSetNo, SqlString command)
.

without the insert into the following produces one resultset as expected:
Exec tSQLt.ResultSetFilter 1, 'EXEC dbo.spr_sel_BolusHistoryByUserID
Exec tSQLt.ResultSetFilter 2, 'EXEC dbo.spr_sel_BolusHistoryByUserID

with the insert into the following produces the exception above:
Insert Into actual
Exec tSQLt.ResultSetFilter 1, 'EXEC dbo.spr_sel_BolusHistoryByUserID

CREATE TABLE [dbo].[actual](
[BolusRequestID] [int] NOT NULL,
[BolusRequestDateTime] varchar NOT NULL,
[UploadID] [int] NOT NULL,
[IndexID] [int] NOT NULL,
[BolusID] [numeric](8, 3) NOT NULL,
[BolusTypeID] [int] NOT NULL,
[BolusType] varchar NOT NULL,
[BolusTypeDesc] varchar NOT NULL,
[OptionTypeID] [int] NOT NULL,
[OptionTypeDesc] nvarchar NOT NULL,
[IsStandard] [int] NOT NULL,
[IsExtended] [int] NOT NULL,
[IsQuick] [int] NOT NULL,
[BG] [int] NOT NULL,
[IOB] [numeric](15, 14) NOT NULL,
[StandardPercent] [int] NOT NULL,
[Duration] [int] NOT NULL,
[CarbSize] [int] NOT NULL,
[IsOverride] [int] NOT NULL,
[CorrectionBolusIncluded] [int] NOT NULL,
[TargetBG] [int] NOT NULL,
[CorrectionFactor] [int] NOT NULL,
[FoodBolusSize] [int] NOT NULL,
[CorrectionBolusSize] [int] NOT NULL,
[ActualTotalBolusRequested] [int] NOT NULL,
[DeclinedCorrection] [int] NOT NULL,
[BolusActivationDateTime] varchar NOT NULL,
[BolusCompletionID] [int] NOT NULL,
[BolusCompletionDateTime] varchar NOT NULL,
[BolusCompletionStatusID] [int] NOT NULL,
[BolusCompletionStatusType] varchar NOT NULL,
[BolusCompletionDesc] varchar NOT NULL,
[BCIOB] [numeric](15, 14) NOT NULL,
[InsulinDelivered] [int] NOT NULL,
[InsulinRequested] [int] NOT NULL,
[BolusActivationID] [int] NULL,
[BolusActivationIndexID] [int] NULL,
[BolexSize] [int] NULL,
[BolexActivationDateTime] [int] NULL,
[BolexCompletionID] [int] NULL,
[BolexCompletionIndexID] [int] NULL,
[ExtendedInsulinDelivered] [int] NULL,
[BolexCompletionStatusID] [int] NULL,
[BolexCompletionStatusType] [int] NULL,
[BolusCompletionDesc_44] [int] NULL,
[BolexCompletionDateTime] [int] NULL,
[InsulinRequested_46] [int] NULL
)

@clifton-collins3iii
Copy link

A follow up on the previous message.
The second result inserts successfully into actual2

Insert Into actual2
Exec tSQLt.ResultSetFilter 2, 'EXEC dbo.spr_sel_BolusHistoryByUserID ''EC3B805E-7B98-417C-A85F-7CADF58A7BB5'',''2019-12-18'',''2019-12-18'',''RAW'',NULL,1,NULL,0'

CREATE TABLE [dbo].[actual2](
[@type] varchar NOT NULL,
[EventID] [int] NOT NULL,
[BolusID] [int] NULL,
[EventDateTime] varchar NOT NULL,
[IOB] [numeric](3, 2) NOT NULL
)

@tSQLt-robot
Copy link
Collaborator

tSQLt-robot commented Jan 14, 2022 via email

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

No branches or pull requests

3 participants