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

Allow to pass table option signed for primary key #768

Merged
merged 3 commits into from
Jun 5, 2017

Conversation

DimazzzZ
Copy link
Contributor

Just new pull request for #658 made by @Serhioromano. Very useful feature.

Are additional tests required?

@DimazzzZ
Copy link
Contributor Author

Please check my fixes in tests, are they correct? The main idea is that table column that is used in FK must be unsigned as referenced table's pk is.

@rquadling
Copy link
Collaborator

Will these changes still allow me to create a signed primary key? I think the tests are now only looking for unsigned primary keys.

@DimazzzZ
Copy link
Contributor Author

@rquadling yes they allow. For example:

// Default (unsigned)
$this->table('test')->addColumn('name', 'string')->create();

// Custom with signed PK
$this->table('test', ['signed' => true])->addColumn('name', 'string')->create();

I fixed existing tests because of changing default behavior, so I think we need additional tests with signed pk.

@rquadling
Copy link
Collaborator

@DimazzzZ The extra tests to make sure signed PK is still feasible. I'd be wary about changing the default though. Consider all those migrations out there already. Rolling them back and then forward again could lead to issues. Ones that come under the heading of "It used to work and we've not changed anything!".

@DimazzzZ
Copy link
Contributor Author

I understand your concerns about these changes but how many and how often developers make signed PK? Or even other ids? IMHO most of them using hacks like @twoixter's from #250 (thanks him btw).

My position is "table auto increment pk must be unsigned" since AUTO_INCREMENT starts at zero by default and increments in the positive direction.

I'll add more tests as soon as posible.

@twoixter
Copy link
Contributor

Hi @DimazzzZ , couldn't agree more! +1, or better +1,000 to this PR. ;-)

@@ -215,6 +215,7 @@ public function createTable(Table $table)
$column = new Column();
$column->setName('id')
->setType('integer')
->setSigned(isset($options['signed']) ? $options['signed'] : false)
Copy link
Contributor

Choose a reason for hiding this comment

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

This represents a backwards compatibility break as implemented. The way to do it without breaking BC would be to keep the current behavior (signed by default) and respect the signed option to create unsigned PKs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way to do it without breaking BC would be to keep the current behavior (signed by default) and respect the signed option to create unsigned PKs.

I thought about it and that was a second option... On the one hand it breaks a backwards compatibility but on the other hand is signed pk is right behavior or we just want to save backwards compatibility forever? We can inform users via changelog about new pk behavior as it was done with PHP 5.3 support, by the way nobody forbids to download an older version of Phinx.

Also we may add new property to phinx.yml like signed_pk: false or something.

Let's discuss.

@rquadling
Copy link
Collaborator

Minor patch upgrades must not break BC. This is important as people rely on the semantic version numbers.

http://semver.org/

Given a version number MAJOR.MINOR.PATCH, increment the:

MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

So, at best, introduce this as a patch, but allow the user to configure their setup to use unsigned PK, but the default must be signed.

@DimazzzZ
Copy link
Contributor Author

DimazzzZ commented Feb 1, 2016

@rquadling okay this is a good reason. I'll set it as signed for now.

May we set this behavior as default in the major 1.0 version?

@DimazzzZ
Copy link
Contributor Author

DimazzzZ commented Feb 2, 2016

Added fix as a minor patch with signed default behavior and new tests. Check this out please.

Who can restart Scrutinizer task or just merge the PK?

@rquadling
Copy link
Collaborator

We have to wait for merges. Takes a while sometimes.

@shadowhand
Copy link
Contributor

Looks good to me. @robmorgan do you have any objections to this?

@shadowhand
Copy link
Contributor

Can you add this option to the docs?

@DimazzzZ
Copy link
Contributor Author

I was in hospital, sorry. The docs has been updated.

@rquadling
Copy link
Collaborator

Hope all is OK.

@deizel deizel mentioned this pull request Mar 4, 2016
2 tasks
@DimazzzZ
Copy link
Contributor Author

@rquadling all is ok, thanks!

Any updates on this PR?

@rquadling
Copy link
Collaborator

Still waiting for Rob.

@DimazzzZ
Copy link
Contributor Author

Version 0.6.x released but PR still opened... Should I re-create PR for 0.6.x branch? (

@rquadling
Copy link
Collaborator

Hi. Please do.

@magnus-eriksson
Copy link

Is there any ETA on this patch?

@Serhioromano
Copy link

Or my goodness! For one line change more than 100 lines of testing. That is what I call testing obsession. Technologies are good, but sometimes they just overkill.

@DimazzzZ thank you for this PR. Hope it gets accepted.

@robmorgan robmorgan changed the base branch from 0.5.x-dev to 0.6.x-dev September 29, 2016 08:03
@robmorgan
Copy link
Member

I can accept this if the default is unsigned however I think the docs need to be updated to say its MySQL specific.

@DimazzzZ
Copy link
Contributor Author

@robmorgan so I update for unsigned default behavior? As @rquadling says it may cause backward compatibility problems for < v.0.6.*.

@dmarklund
Copy link

Any updates to this PR?

@jakejohns
Copy link

any word here?

@magnus-eriksson
Copy link

Version 0.8 is now out and this is still open? Any ETA?

@robmorgan robmorgan changed the base branch from 0.6.x-dev to master June 5, 2017 12:09
@robmorgan robmorgan merged commit 418a6b6 into cakephp:master Jun 5, 2017
@robmorgan
Copy link
Member

I tweaked the docs a little bit. I was on the fence about renaming the signed table option to unsigned_primary_key, but I've left it alone for now. I'll ship it later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants