Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Integer vs BigInteger diffrence are not checked #341
Migrated issue, originally created by akamyshnikova (@akamyshnikova)
I have a model
And a migration script
If I run
to check such changes, new script migration is not created and difference between Integer and BigInteger is not detected.
Note, that changes between Integer and String are checked.
Michael Bayer (@zzzeek) wrote:
this is currently expected behavior because the default type comparison logic is intentionally very conservative, so as not to produce false positives. Otherwise, if the model contains Integer, and the database contains mysql.INTEGER, these are not actually the "same" type; INTEGER is much more specific. So the comparison is done using "type affinity" alone, and in SQLAlchemy a BigInteger and Integer, as well as all their descendant types, have the same affinity.
However, there are two specific comparator functions _string_compare and _numeric_compare that are added to grant more specificity to these types, so in the case of Integer we can add one of these.