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

Clarify precision/scale #314

Open
dereuromark opened this issue Apr 2, 2017 · 4 comments
Open

Clarify precision/scale #314

dereuromark opened this issue Apr 2, 2017 · 4 comments
Milestone

Comments

@dereuromark
Copy link
Member

dereuromark commented Apr 2, 2017

I think we need to clarify the differences between Cake and Phinx, regarding the option keys precision, scale and limit.

The correct phinx migrations lines are:

$table->changeColumn('lat', 'float', [
			'default' => null,
			'null' => true,
			'precision' => 10,
			'scale' => 6,
		]);
		$table->changeColumn('lng', 'float', [
			'default' => null,
			'null' => true,
			'precision' => 10,
			'scale' => 6,
		]);

In the fixtures it is, though:

'lat' => [
    'type' => 'float', 
    'length' => 10, 
    'precision' => 6,
    'unsigned' => false, 
    'null' => true, 
    'default' => null,
],
'lng' => [
    'type' => 'float', 
    'length' => 10, 
    'precision' => 6, 
    'unsigned' => false, 
    'null' => true, 
    'default' => null,
],

precision/scale vs length/precision can be rather confusing IMO.

@dereuromark
Copy link
Member Author

Is there anyone with similar experience - and some more insight?
We could make a small note in the docs here to avoid other people to trip over the same thing.

@markstory
Copy link
Member

That is pretty confusing. We could start accepting scale in the fixtures. But changing the meaning of precision in either migrations or fixtures is going to be problematic.

@HavokInspiration
Copy link
Member

This is regular problem with phinx : some options are not named the same. The signed / unsigned features on numeric columns was also a problem. We implemented it as some DB engines do (with an unsigned option ; phinx did it the other way around, with a signed option.

Same thing goes for the autoIncrement feature. Phinx implements it with a identity named option.

This is what I did in the past to offer a more common interface : https://github.com/cakephp/migrations/blob/master/src/Table.php#L51-L54

But I'm not sure this is good, it adds a bit of complexity when maintaining.

@HavokInspiration
Copy link
Member

As for a note in the docs why not... It can't hurt much.

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

No branches or pull requests

3 participants