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 state is 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.
Old
if (is.null(version) || is.na(version) || length(version) == 0), the variable version is a vector of count > 1.
New
if (is.null(version) || any(is.na(version)) || length(version) == 0), uses any() 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=FALSE is passed to test_that's expect_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 invalid experience in certain commands due to the getServerVersion() function not utilizing the T-SQL execution option WITH 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 length that appeared due to an object not guaranteed to be of size 1.
packageProperties <- availablePackages[availablePackages$Package == package & availablePackages$Repository == contributorURL, ] where contributorURL is assigned the first element of the previously compared object contribWinBinaryUrl. More than one URL may be present if the SQLMLUtils environment is unexpectedly set with more than one repository source using options(repos='xx').
How is this change tested?
[x] Pass all existing unit tests
[x] Added unit test to explicitly run checkServerVersion() to validate that the Cursor State Invalide error is not encountered.
Calling && or || with either argument of length greater than one now gives a warning (which it is intended will become an error).
Calling if() or while() with a condition of length greater than one gives an error rather than a warning. Consequently, environment variable _R_CHECK_LENGTH_1CONDITION no longer has any effect.
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 state
is 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 variableversion
is 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=FALSE
is passed to test_that'sexpect_equal
which 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 invalid
experience 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 length
that appeared due to an object not guaranteed to be of size 1.packageProperties <- availablePackages[availablePackages$Package == package & availablePackages$Repository == contributorURL, ]
wherecontributorURL
is 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 Invalide
error is not encountered.References
[1] - Changes in R4.2