-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Forward compatibility with 3.x #2996
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice cleanup. 👍
Travis caught some CS issues on modified lines that are not directly caused by this PR.
lib/Doctrine/DBAL/ColumnCase.php
Outdated
/** | ||
* Contains portable column case conversions. | ||
*/ | ||
class ColumnCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make these final, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I took it as is from your draft and though final private function __construct()
is enough. But it only prohibits instantiation, not extension.
\PDO::PARAM_INT => DB2_LONG, | ||
\PDO::PARAM_STR => DB2_CHAR, | ||
ParameterType::INTEGER => DB2_LONG, | ||
ParameterType::STRING => DB2_CHAR, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we align array members the same way as assignments? 🤔
* | ||
* @return boolean TRUE on success or FALSE on failure. | ||
*/ | ||
function bindValue($param, $value, $type = null); | ||
|
||
public function bindValue($param, $value, $type = ParameterType::STRING); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't change of default here from null to string BC breaking? (Applies to other signature changes as well.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP is fine with that judging by https://3v4l.org/95JYL. Semantically, both null
and ParameterType::STRING
are the same since the latter is used by default in all implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be cautious with that. Does the test suite at least contain a test with bindValue()
called with only 2 parameters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius there is a test like that:
$stmt->bindValue(1, 1); |
This change indeed was only required for develop
to make this code work:
return $this->stmt->bindValue($param, $value, $type); |
because NULL
appears to not be a valid type for PDO:
$conn = new PDO('mysql:host=localhost;dbname=mysql');
$stmt = $conn->prepare('SELECT ?');
$stmt->bindValue(1, 'foo', null);
$stmt->execute();
$value = $stmt->fetchColumn();
var_dump($value);
// NULL
I understand your concern but I don't know what to look for. I manually checked all implementations, and they all either default to binding as string explicitly (IBM DB2, MySQLi, PDO) or don't specify the string/null type at all (OCI8, SQL Server) or seem to not even accept NULL
(SQLAnywhere).
I can revert changes in all Statement::bind*()
signatures if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine if a test already exists and doesn't explicitly pass the third argument to bindValue()
.
My only issue was that without a test verifying the default parameter we'd have a stability problem :-)
And yes, PDO is (as usual) being weird with default values :-P
@Majkl578 looks like some of the code style violations are reported on wrong lines. For instance:
The |
I noticed that too while working on #2998. The errors seem to be reported for the element they're connected to. See here - |
@Majkl578 I think we can live with that. I suspect it may be hard to justify the needed changes in a 3rd-party library (not speaking of that someone will have to implement them). On the other hand, we could get rid of the false positives by fixing annotations. Maybe @carusogabriel could take a look? 😉 |
@morozov How can I help? 🤓 |
@morozov Reported here: slevomat/coding-standard#250. It should be trivial to fix for LongTypeHInt sniff, but not sure about TypeHintDeclaration sniff which is pretty complex already. I hope 2.7 will be shipped anytime soon and then we can merge develop & apply CS same as we did in ORM. 😎 |
Try |
@kukulich Awesome, thanks! @morozov Retriggerred the CS stage: https://travis-ci.org/doctrine/dbal/jobs/334442418#L524, can you check now? |
@carusogabriel judging by CI failures, we have some |
@Majkl578, @kukulich thank you for the update. There's one more false positive like the fixed ones:
Unlike those, it doesn't seem possible to fix on the standard side since it reports the absence of annotation. Unless you have an idea. @carusogabriel, mind fixing issues like this as well? |
@morozov No problem. I'm just finishing some stuff, I'll PR separately the annotation types and missing |
The standard doesn't account for PHPUnit annotations. |
This last one is ours, configuration issue - we do have most of the common annotations whitelisted, but I probably forgot this one ( |
Argh, the CS changes introduced recently led to a few merge conflicts here, @morozov. Sorry! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall good improvement. Besides a change in a test that isn't really clear to me, this is good to go 👍
@@ -217,7 +240,7 @@ public function databaseUrls() | |||
false, | |||
), | |||
'URL without scheme but default PDO driver' => array( | |||
array('url' => '//foo:bar@localhost/baz', 'pdo' => $pdoMock), | |||
array('url' => '//foo:bar@localhost/baz', 'pdo' => true), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a test change that I don't understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Ocramius look at the changes in testDatabaseUrl()
. Instead of creating mock, the data provider passes a flag to the test method. It will either create the mock if PDO is loaded or will skip the data set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it 👍
…ndency on the actual constant values
97ef0b0
to
4190669
Compare
I believe we can ignore the code style CI failure for this PR. My entire idea of line-based validation was to avoid the "Fixed code style" commits. But given that this one is a back-port from |
@Ocramius anything else you want to get done before merging this? |
Nope, 🚢 |
Handled further CS in #3002 |
@@ -20,7 +20,8 @@ | |||
namespace Doctrine\DBAL\Driver\SQLSrv; | |||
|
|||
use Doctrine\DBAL\Driver\StatementIterator; | |||
use PDO; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is bug - there is still unqualified PDO::FETCH_ORI_NEXT
reference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like the only place like this. Please see #3024.
This is a back-port of non-BC-breaking part of #2958.
Fixes #2953.