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

Don't null size field when scale specified #621

Closed
wants to merge 3 commits into from
Closed

Don't null size field when scale specified #621

wants to merge 3 commits into from

Conversation

fliespl
Copy link
Contributor

@fliespl fliespl commented Feb 26, 2013

This is an issue that I come upon using propel migration. It always tried to migrate my decimal column with the same values.

After inspecting closely I have figured that reverse schema parser sets null to $size variable (even if $scale) is specified.

This way, when migrator compares columns it has $size = 10 in schema.xml and $size = null in database (because reverse mysql class changes native sizes to null).

Real life example:
XML:
latitude: { phpName: Latitude, type: DECIMAL, size: 10, scale: 7, required: false }

DB:
  latitude decimal(10,7) DEFAULT NULL,

produces migration queries as such:

getUpSQL:
ALTER TABLE venues CHANGE latitude latitude DECIMAL(10,7);

getDownSQL:
ALTER TABLE venues CHANGE latitude latitude DECIMAL;

As you can see in getDownSQL, database reverse parser didn't account for size+scale combination and assumed that size is 10,0.

This is an issue that I come upon using propel migration. It always tried to migrate my decimal column with the same values.

After inspecting closely I have figured that reverse schema parser sets null to $size variable (even if $scale) is specified.

This way, when migrator compares columns it has $size = 10 in schema.xml and $size = null in database (because reverse mysql class changes native sizes to null).

Real life example:
XML:
latitude: { phpName: Latitude, type: DECIMAL, size: 10, scale: 7, required: false }

DB:
  `latitude` decimal(10,7) DEFAULT NULL,


produces migration queries as such:

getUpSQL:
ALTER TABLE `venues` CHANGE `latitude` `latitude` DECIMAL(10,7);

getDownSQL:
ALTER TABLE `venues` CHANGE `latitude` `latitude` DECIMAL;


even though database is already set propely with size and scale.
@staabm
Copy link
Member

staabm commented Feb 26, 2013

You have an parse error in your PR. you should add a failing unit-test before fixing the issue.

@staabm
Copy link
Member

staabm commented Feb 26, 2013

why don't you add the test to the test-suite with this PR?

@staabm
Copy link
Member

staabm commented Mar 3, 2013

@fliespl the tests are not green anymore... are you willing to have another look into it?

@fliespl
Copy link
Contributor Author

fliespl commented Mar 3, 2013

Could you please explain what should I do?

jaugustin added a commit that referenced this pull request Mar 10, 2013
jaugustin added a commit that referenced this pull request Mar 10, 2013
Don't null size field when scale specified
@jaugustin
Copy link
Member

@fliespl I merged your PR thanks

I modified your tests to make them work ;)

@jaugustin jaugustin closed this Mar 10, 2013
@fliespl
Copy link
Contributor Author

fliespl commented Mar 11, 2013

@jaugustin thanks for both tests and merge :)

@fliespl fliespl deleted the patch-1 branch October 22, 2014 11:28
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants