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

sql variant support #399

Merged
merged 21 commits into from
May 18, 2017
Merged

sql variant support #399

merged 21 commits into from
May 18, 2017

Conversation

Hadis-Knj
Copy link

@Hadis-Knj Hadis-Knj commented May 17, 2017

Limitation

  • sqlvariant is not supported for output parameters, and operand type clash error is expected.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 67.955% when pulling b31ee17 on Hadis-Fard:dev into 4537021 on Microsoft:dev.


SQLSTATE[22018]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: nvarchar(max) is incompatible with sql_variant
SQLSTATE[22018]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: nvarchar(max) is incompatible with sql_variant

Copy link
Contributor

Choose a reason for hiding this comment

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

Where did nvarchar(max) come from?? The error messages don't make sense here...?

Copy link
Author

Choose a reason for hiding this comment

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

the initialized data is php string that will fall into sql varchar* type group, in the core stmt when binding output parameters the size is assigned to max to avoid silent truncation. so when it is passed to ODBC the type is max, and the server receives the max char type. For error handling in this part we're benefiting from server side errors, as we cannot identify the type of the variant column beforehand (the same reason why we cannot support output parameters), and we can't constraint the error SQLSTATE[22018] to only variant, and it might occur when querying other columns than variant.

@@ -0,0 +1,194 @@
--TEST--
Test simple insert and fetch sql_variants as strings using inputs of various data types
Copy link
Contributor

Choose a reason for hiding this comment

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

This test looks so much similar to sqlsrv/sqlsrv_simple_fetch_variants.phpt? What's the difference?

Copy link
Author

Choose a reason for hiding this comment

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

Oops, accidentally checked this in 😃


echo "Insert all columns from row $c1_int into one column of type sql_variant\n";
$stmtOriginal->bindValue(':row', $c1_int, PDO::PARAM_INT);

Copy link
Contributor

Choose a reason for hiding this comment

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

What if the user calls bindValue() without specifying the type? Will there be an error?

Copy link
Contributor

@yitam yitam left a comment

Choose a reason for hiding this comment

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

will there be a test with query like select ? = name from...

@coveralls
Copy link

Coverage Status

Coverage increased (+0.03%) to 67.867% when pulling 063e8b3 on Hadis-Fard:dev into 4537021 on Microsoft:dev.

@Hadis-Knj
Copy link
Author

issue #51 and #127

@coveralls
Copy link

Coverage Status

Coverage increased (+7.3%) to 75.145% when pulling aeac4e6 on Hadis-Fard:dev into 4537021 on Microsoft:dev.

@Hadis-Knj Hadis-Knj merged commit 29bb602 into microsoft:dev May 18, 2017
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.

4 participants