8000 DateIntervalType (negative support) resolves doctrine/dbal#2578 by galeaspablo · Pull Request #2579 · doctrine/dbal · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

DateIntervalType (negative support) resolves doctrine/dbal#2578 #2579

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

Merged
merged 2 commits into from
Mar 29, 2018
Merged

DateIntervalType (negative support) resolves doctrine/dbal#2578 #2579

merged 2 commits into from
Mar 29, 2018

Conversation

galeaspablo
Copy link
Contributor

No description provided.

@galeaspablo
Copy link
Contributor Author

If #2316 is merged before this, we'll need to refactor this PR.

@@ -56,9 +58,13 @@ public function convertToPHPValue($value, AbstractPlatform $platform)
}

try {
return new \DateInterval($value);
$interval = new \DateInterval(substr($value, 1));
Copy link
Member

Choose a reason for hiding this comment

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

With this you assume that $value always have the sign, which is not the case for existing data.
We should make sure that the type would still work for the "old" format.

Copy link
Member

Choose a reason for hiding this comment

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

We should make sure that the type would still work for the "old" format.

Testing it too 😉

Copy link
Contributor Author
@galeaspablo galeaspablo Dec 15, 2016

Choose a reason for hiding this comment

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

I don't think \DateInterval accepts a leading + or -.
How about?

try {
            $firstCharacter = substr($value, 0, 1);
            if ($firstCharacter !== '+' && $firstCharacter !== '-') {
                  return new \DateInterval($value);
            }
            $interval = new \DateInterval(substr($value, 1));
            if ($firstCharacter === '-') {
                 $interval->invert = 1;
             }
             return $interval;
}

Edit Also, just realized. This change is for BC, inside the development branch. I don't think we should be doing this. That's a big can of worms to open. For instance, there's another pull request that might change the whole format #2316

Copy link
Member

Choose a reason for hiding this comment

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

My 2 cents on this. As already pointed out, this is a BC break that cause schema changes and format changes, which we cannot accept for a minor release. We could however introduce a new type like SignedDateIntervalType to keep BC.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this really a BC break? This isn't on 2.5.

Copy link
Member

Choose a reason for hiding this comment

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

@galeaspablo oh you are right I thought it was part of 2.5 already. Thanks for pointing that out, then we won't have a problem with BC indeeed :)

@jonny-no1
Copy link

Any update on this? Would you go ahead with the merge with the solution from #2579 (comment), @lcobucci?

@Ocramius
Copy link
Member

After looking at it with @sebastianfeldmann at the DPC code night, I'd say that this is NOT ready to be deployed. Instead, a new type is needed, because this kind of change would mean that users of the library would have half the data WITH the sign, and half the data without.

In addition to that, binding with the sign would change behavior: queries using parameter binding would be broken.

That's the way to go IMO, whereas the existing type would have to stay unchanged.

@Ocramius
Copy link
Member

Closing and pushing discussion back to #2578

@Ocramius Ocramius closed this Jun 29, 2017
@Ocramius Ocramius self-assigned this Jun 29, 2017
@Ocramius
Copy link
Member

Re-opening as per #2579 (comment) - sorry @galeaspablo!

@galeaspablo
Copy link
Contributor Author

#2316 was merged. Through it, the database value format was changed. As I said before, this means that I had to refactor my PR.

I've refactored my PR to work with the new master branch (i.e. handle negative support with the new format).

lcobucci
lcobucci previously approved these changes Jul 23, 2017
Copy link
Member
@lcobucci lcobucci left a comment

Choose a reason for hiding this comment

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

Just synced with master. LGTM

@Ocramius
Copy link
Member

@lcobucci as mentioned before, the fact that I released early is my fuckup (technical terminology).

We discussed it earlier tonight, and while it is technically possible for us to introduce a quick 2.6.1 with the change in it, nothing denies folks to install 2.6.0 now, then upgrade and have it broken later.

This PR is now a BC break, and I don't think we can fix it without introducing a SignedDateIntervalType.

@galeaspablo I apologise, this will need some rework :-(

@Ocramius Ocramius added this to the 2.7 milestone Jul 23, 2017
@Ocramius Ocramius added the WIP label Jul 23, 2017
@galeaspablo
Copy link
Contributor Author

Haha. Shit happens (technical terminology). So SignedDateIntervalType would get merged?

@Ocramius
Copy link
Member

I think so. @deeky666 @lcobucci thoughts?

@lcobucci
Copy link
Member

#2578 is labeled as a bug and the PR is an improvement. If we tackle it as an improvement I with a new type (maybe even deprecating the existing one), however if we see it as a bug I'd rather change the PR in a way that doesn't break BC.

We also need to keep in mind that new features will land just on 2.7.

@Majkl578
Copy link
Contributor

Hi, shall we consider this a blocker for 2.7? If so, it needs a rebase & fixing the conflicts, otherwise we could push this back to 2.8/3.0 and decide later.

@morozov morozov requested a review from Ocramius March 29, 2018 03:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0