Feature, Public API | Enable SqlDataRecord support for TVPs with computed columns - #4654
Draft
edwardneal wants to merge 5 commits into
Draft
Feature, Public API | Enable SqlDataRecord support for TVPs with computed columns#4654edwardneal wants to merge 5 commits into
edwardneal wants to merge 5 commits into
Conversation
Note that a computed column will (by definition) always have a default value, so setting IsComputed also implies the same effect as UseServerDefault.
Note that the previous commit means that IsComputed will also result in the fDefault bit being set.
This is an init property, so requires a shim on net462 and netstandard.
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The MS-TDS spec supports a client recognising that a field in a table-valued parameter might well be computed by the server. An example of a TVP which does this is:
Under such circumstances, the client can set the
fComputedbit in theTVP_COLMETADATAdefinition. We also need to set thefDefaultbit - without setting this, SQL Server expects the client to send a value for the computed column, and throws an exception indicating that I'm trying to overwrite a computed column with a value when we send one.Once the
fComputedbit is set, the computed columns in the TVP are populated by SQL Server as we'd expect.Enabling the client to set this necessitates a public API change of some form. In this case, I've added an
IsComputedproperty toSqlMetaData:This is a slightly different approach to the public API than the current set of constructors, but I think it's the most practical one - I think most of the constructors would want to be able to specify whether the field is computed, and we'd essentially double the number of constructors if adding a separate parameter to all of them.
I'm leaving this PR in draft until there's time for the public API to be reviewed. Once we're happy with it, I'll adjust the API surface accordingly.
@mdaigle - this intersects with some of the work you'd been doing on the issue and provides a fix for
SqlDataRecord.Issues
Fixes #3242. It doesn't introduce anything to enable
DataTable- orDbDataReader-based support, but I don't think there's a way to enable that support client-side.Testing
New manual tests have been added, and all pass.