-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support second, minute, week, year on DATE_ADD and DATE_SUB #6742
Add support second, minute, week, year on DATE_ADD and DATE_SUB #6742
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.
Overall, patch looks good, but misses testing (especially integration with other DBs
@@ -51,7 +51,11 @@ public function getSql(SqlWalker $sqlWalker) | |||
$this->firstDateExpression->dispatch($sqlWalker), | |||
$this->intervalExpression->dispatch($sqlWalker) | |||
); | |||
|
|||
case 'minute': |
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 spotted some \t
here ;-)
Can i do something again ? |
Looks good to me: so far. Assigning to @lcobucci for another pair of eyes. |
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.
It LGTM, just some nitpicking. Also, aren't we missing tests for year and week add/sub?
/** | ||
* @group DDC-2938 | ||
*/ | ||
public function testDateAddTime() |
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.
Please add : void
{ | ||
$arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'second') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") | ||
->getArrayResult(); | ||
$this->assertTrue(strtotime($arg[0]['add']) > 0); |
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.
Use self::assert*()
instead
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.
Wouldn't be better to use a more specific assertion?
|
||
$arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'hour') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") | ||
->getArrayResult(); | ||
$this->assertTrue(strtotime($arg[0]['add']) > 0); |
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.
Use self::assert*()
instead
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.
Wouldn't be better to use a more specific assertion?
|
||
$arg = $this->_em->createQuery("SELECT DATE_ADD(CURRENT_TIMESTAMP(), 10, 'minute') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") | ||
->getArrayResult(); | ||
$this->assertTrue(strtotime($arg[0]['add']) > 0); |
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.
Use self::assert*()
instead
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.
Wouldn't be better to use a more specific assertion?
{ | ||
$arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'second') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") | ||
->getArrayResult(); | ||
$this->assertTrue(strtotime($arg[0]['add']) > 0); |
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.
Use self::assert*()
instead
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.
Wouldn't be better to use a more specific assertion?
|
||
$arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'minute') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") | ||
->getArrayResult(); | ||
$this->assertTrue(strtotime($arg[0]['add']) > 0); |
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.
Use self::assert*()
instead
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.
Wouldn't be better to use a more specific assertion?
|
||
$arg = $this->_em->createQuery("SELECT DATE_SUB(CURRENT_TIMESTAMP(), 10, 'hour') AS add FROM Doctrine\Tests\Models\Company\CompanyManager m") | ||
->getArrayResult(); | ||
$this->assertTrue(strtotime($arg[0]['add']) > 0); |
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.
Use self::assert*()
instead
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.
Wouldn't be better to use a more specific assertion?
@@ -335,6 +353,24 @@ public function testDateSub() | |||
} | |||
|
|||
/** | |||
* @group DDC-2938 | |||
*/ | |||
public function testDateSubTime() |
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.
Please add : void
@lcobucci I cannot change for |
@Legenyes you can change for the code you're inserting. |
It's worse. What about BC for |
This patch would land in 2.6 only, which is 7.1 only anyway
…On 4 Oct 2017 12:08, "Sébastien Lévêque" ***@***.***> wrote:
It's worse.
Mixing two syntax in the same file is not a good practice.
I will not make this change in this PR
What about BC for : void ?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6742 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJakIsNIeuJfwNJ6M0wMq73_S22-w2Cks5so1kmgaJpZM4Pqbxg>
.
|
@Legenyes I agree that it's not ideal to have mixed syntaxes but it is the least worse solution, given this context. |
What' news ? |
@Legenyes we still don't have tests for |
The docs currently say:
please change that too (add your units, and change "number of days") |
Closes #5835 ? |
So that we can do proper assertions and cover all the possibilities of the functions.
This wasn't in the docs yet, leading me to a search for how to do it. Luckily i found this old PR. I've created a PR to add this to the docs. |
The DATE_ADD and DATE_SUB built-in function of Doctrine supports only the "hour", "month" and "day" intervals. I don't see the point of not having all the intervals available. These should be "minute", "second" and "year". I didn't check compatibility with other database vendors rather than MySQL but I don't think it should be a problem
Cfr Also Ticket #3698