Fix R Unit Tests and Invalid Cursor State Occurrences#100
Merged
seantleonard merged 11 commits intomasterfrom Jul 11, 2022
Merged
Fix R Unit Tests and Invalid Cursor State Occurrences#100seantleonard merged 11 commits intomasterfrom
seantleonard merged 11 commits intomasterfrom
Conversation
jarupatj
approved these changes
Jul 7, 2022
monamaki
approved these changes
Jul 8, 2022
65199be to
8d034a1
Compare
Contributor
Author
|
11 commits were just rewritten to ensure they were all signed, to facilitate merging. No content changes occurred. |
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.
Why is this change being made?
This change enables compatibility with R 4.2, which consequently introduces support for SQL Server 2022 starting with CTP2.0. Additionally, the fix for certain queries experiencing the error
Invalid cursor stateis included.What does this change do?
Due to changes introduced in R 4.2[1], warnings like
length(x) = 5 > 1' in coercion to 'logical(1)'were surfacing. This was fixed with corrected conditional logic.if (is.null(version) || is.na(version) || length(version) == 0), the variableversionis a vector of count > 1.if (is.null(version) || any(is.na(version)) || length(version) == 0), usesany()to determine, given a set of logical vectors, that at least one of the values is true.In test.executeInSqlTests.R the test Returning a function object was checking that execution of a function in SQL Server would return the function result matching that defined locally. In order for this check to succeed based on equality of the function content, the optional parameter
check.environment=FALSEis passed to test_that'sexpect_equalwhich behind the scenes uses base::identical() to ignore the environment differences that are present because the function objects were created in different R environments (client/server).Add support for special characters in the connection string password for test_that tests by escaping the pwd attribute value with curly braces. SQL Server ODBC Doc Reference
Remediates instances of the error
cursor state invalidexperience in certain commands due to thegetServerVersion()function not utilizing the T-SQL execution optionWITH RESULT SETS. Due to underlying behavior of the utilized ODBC drivers, the execution option is necessary to ensure a result set is properly parsed by the driver interface code. The fix adds the execution option to the relevant code path.Fixes warning
longer object length is not a multiple of shorter object lengththat appeared due to an object not guaranteed to be of size 1.packageProperties <- availablePackages[availablePackages$Package == package & availablePackages$Repository == contributorURL, ]wherecontributorURLis assigned the first element of the previously compared objectcontribWinBinaryUrl. More than one URL may be present if the SQLMLUtils environment is unexpectedly set with more than one repository source usingoptions(repos='xx').How is this change tested?
checkServerVersion()to validate that theCursor State Invalideerror is not encountered.References
[1] - Changes in R4.2