PDO_DBlib: stringify 'uniqueidentifier' fields#2001
PDO_DBlib: stringify 'uniqueidentifier' fields#2001turboezh wants to merge 14 commits intophp:PHP-7.0from
Conversation
Keep old 5.6 behavior: return Uniqidentifier value as 36-byte hex string (not binary), when PDO::ATTR_STRINGIFY_FETCHES is TRUE
Keep old 5.6 behavior: return Uniqidentifier value as 36-byte hex string (not binary), when PDO::ATTR_STRINGIFY_FETCHES is TRUE Tests added.
Keep old 5.6 behavior: return Uniqidentifier value as 36-byte hex string (not binary), when PDO::ATTR_STRINGIFY_FETCHES is TRUE Tests fix.
|
@adambaratz could you please check this PR? Thanks. |
ext/pdo_dblib/tests/types.phpt
Outdated
| bool(true) | ||
| bool(true) | ||
| bool(true) | ||
| bool(true) |
There was a problem hiding this comment.
This fails for me. The column type comes back as SQLBINARY (45), so it's handled differently.
There was a problem hiding this comment.
SQLUNIQUE (SYBUNIQUE) is available only since TDS 7.0. =( Maybe I'm wrong, I can't test it with all variants of databases. But when I set tds version 4.6 it really comes as SQLBINARY (45), tds version 6.0+ gives SQLUNIQUE (36).
Must the extension behave identically at all tds versions? I think 4.* versions should be left off as unsupported by this option. If so I will try to fix the test accordingly.
There was a problem hiding this comment.
Ah, my test VM had the older version set. Looks fine now. I think ideally we would skip this test for older TDS versions, but I don't think we can detect that from PHP/PDO. Maybe just add a comment saying why this test might fail?
There was a problem hiding this comment.
There are PDO attributes that are not implemented in pdo_dblib now: PDO::ATTR_SERVER_INFO, PDO::ATTR_SERVER_VERSION, PDO::ATTR_CLIENT_VERSION. They could be used to reveal some info about connection including TDS protocol version. But I think it is a task for a separate PR. I'll put a comment about possible fail in the test now with a TODO about these attrs.
|
I'd recommend this behavior be opt-in. I made this (breaking) change in the interest of making this extension work the same was as the (deprecated) mssql extension. So, my fault. But we should allow both behaviors to handle both sets of expectations. A boolean driver attribute would do the job. |
Could you please give me a hint how to name it? |
|
That attribute name is perfect. |
Added separate PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER attribute instead of PDO::ATTR_STRINGIFY_FETCHES.
Added `getAttribute` support for PDO::DBLIB_ATTR_STRINGIFY_UNIQUEIDENTIFIER.
|
Ready for another review. |
|
Thanks for doing the cleanup. Test coverage is good. Unit tests run clean, with/without valgrind. There are some slight changes that I think are worth making to the attribute handling, making the code and the memory usage more concise. I put these up on a remote branch. If you cherry pick that commit onto your branch, you'll be good to go. |
|
Done. |
|
@weltling: this is ready to be merged. |
|
The exact part from ext/pdo_dblib/tests/stringify_uniqueidentifier.phpt fails with the default setting. I've tried so far to set @adambaratz please send a request to internals for becoming a maintainer. Once you have git access, you'll be able to merge PRs yourself. Thanks for your work, guys! |
|
Merged with a000bff. Thanks! |
|
please document this feature |
|
Agree with @stayeronglass, this should be documented. I have an API that depends on a MSSQL connection and have yet to be able to get it to upgrade to PHP 7 due to this GUID problem. How do we restore the human readable output? |
|
@stayeronglass, @tylerssn, @adambaratz.
|
|
has this option been replaced as |
|
@joelharkes, no, this attribute is still supposed to be supported. Please file a ticket, if you have a PHP with the pdo_dblib extension enabled, and that constant is not defined. |
Before PHP 7.0 pdo_dblib returns
uniqueidentifierfields as 36-byte hex string, a 'human' representation of GUID, like, '82A88958-672B-4C22-842F-216E2B88E72A'.Now such fields returns as 16-byte raw binary string.
I propose keep old behavior and return fields in human representation when
PDO::ATTR_STRINGIFY_FETCHES == true.https://bugs.php.net/bug.php?id=72601