Postgres processor seems to have precision and size mismatched. #303

Closed
dealproc opened this Issue Sep 15, 2012 · 2 comments

Projects

None yet

3 participants

@dealproc
Contributor

When you look at: https://github.com/schambers/fluentmigrator/blob/master/src/FluentMigrator.Runner/Generators/Postgres/PostgresTypeMap.cs, if you go to ~ line 24, where it defines the "Decimal" types, for the one where you want to specify the storage options, it has the size/precision backwards in comparison to the variables being passed into it from the .AsDecimal() method.

E.g., to specify a field with a total length of 18, and a precision of 4, I had to do .AsDecimal(4,18) instead of .AsDecimal(18,4).

This is as of the latest nuget build on 9/15/2012 @ 4:00 AM EDT.

Contributor

Hy,

I changed the defaults based on Postgres Documentation (http://www.postgresql.org/docs/8.1/static/datatype.html)
Unfortunately, I forgot to reverse the generic decimal map as well. :(

It states:
"The types decimal and numeric are equivalent. Both types are part of the SQL standard."
And:
"The scale of a numeric is the count of decimal digits in the fractional part, to the right of the decimal point. The precision of a numeric is the total count of significant digits in the whole number, that is, the number of digits to both sides of the decimal point."

And if you look up Arbitrary Numeric type, it's definition is:
"NUMERIC(precision, scale)"

I think the wording confused the contributor who implemented it. The precision in FluentMigrator's language is "size", and the scale is the "precision".

I guess simply reveresing it in the type map should be enough:

"SetTypeMap(DbType.Decimal, "decimal($precision,$size)", DecimalCapacity);"
To
"SetTypeMap(DbType.Decimal, "decimal($size,$precision)", DecimalCapacity);"

And of course check the tests, why they haven't failed.

@daniellee daniellee added a commit that referenced this issue Sep 28, 2012
@daniellee daniellee Fix issue #303 with Postgres Typemap
Size and precision were in the wrong order for decimal in the type map. Test was also
wrong.
be2ed47
Contributor

Thanks for catching this. Fixed it in this commit: be2ed47

@daniellee daniellee closed this Sep 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment