Cast MySQL bigint(20) into numeric, fix #253.

In MySQL it's possible to have a bigint of 20 digits when using the
"unsigned" variant of the data type, whereas in PostgreSQL there's no
such variant and bigints are "limited" to the range -9223372036854775808
to +9223372036854775807 (19 digits numbers).

Fix the default casting rule to switch to PostgreSQL numeric in such cases.
This commit is contained in:
Dimitri Fontaine 2015-07-17 12:05:28 +02:00
parent a308dd9bda
commit c3986b0997

View File

@ -69,6 +69,11 @@
:target (:type "boolean" :drop-typemod t)
:using pgloader.transforms::bits-to-boolean)
;; bigint(20) unsigned (or not, actually) does not fit into PostgreSQL
;; bigint (-9223372036854775808 to +9223372036854775807):
(:source (:type "bigint" :typemod (< 19 precision))
:target (:type "numeric" :drop-typemod t))
;; we need the following to benefit from :drop-typemod
(:source (:type "tinyint") :target (:type "smallint" :drop-typemod t))
(:source (:type "smallint") :target (:type "smallint" :drop-typemod t))