Skip to content

Conversation

@paulmedynski
Copy link
Contributor

Description

  • Added tests for SqlDataReader.HasRows for responses with and without INFO tokens.
  • Tweaked existing TDS Server bits to emit logs to xUnit output.

- Added tests for SqlDataReader.HasRows for responses with and without INFO tokens.
Copy link
Contributor Author

@paulmedynski paulmedynski left a comment

Choose a reason for hiding this comment

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

Commentary for reviewers.

/// </summary>
public QueryEngine(TdsServerArguments arguments)
{
Log = arguments.Log;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This ensures the engine has its Log set, regardless of what TdsServer may decide.

TDSInfoToken infoToken = new TDSInfoToken(2012, 2, 0, lowerBatchText);
// Create an info token that contains the verbatim query text we
// received (not the lower-cased version).
TDSInfoToken infoToken = new TDSInfoToken(2012, 2, 0, batchRequest.Text);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now the query text in the INFO matches what the test actually sent.

/// Constructor with a query engine. Uses the engine's servers arguments.
/// </summary>
/// <param name="queryEngine">Query engine</param>
public TdsServer(QueryEngine queryEngine)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Convenience constructor to avoid having to specify ServerArguments twice in the test.

{
Log(log, string.Format("{0}[{1}]", prefix, index++), o);
SerializedWriteLineToLog(log, string.Format("{0}: <null>", prefix));
log.Flush();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added missing Flush() calls.

log.WriteLine(string.Format("[{0}] {1}", DateTime.Now, text));
}
var now = DateTime.UtcNow;
log.WriteLine($"[{now:yyyy-MM-dd hh:mm:ss.fff}Z] {text}");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Better timestamp formatting, and changed to UTC.


// We should have read past the INFO tokens and determined that there
// are row results.
Assert.True(reader.HasRows);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was expecting this to fail for infoCount > 1 based on #3018, but it passes. I will investigate further.

@paulmedynski paulmedynski linked an issue Nov 5, 2025 that may be closed by this pull request
- Added placement of INFO tokens as start, middle, and end of the response stream to elicit failures.
- Pinpointed the failing cases and have allowed them to pass for now, with TODOs to address if/when we make a fix to SqlDataReader.
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.

HasRows fails to detect rows

2 participants