Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-21868 mssql generator - improve integer meta type detection

  • Loading branch information...
commit 32feeb023c51bf41b32e4b30717589f339d7109b 1 parent 09b2ffb
@stronk7 stronk7 authored
Showing with 22 additions and 0 deletions.
  1. +22 −0 lib/xmldb/classes/generators/mssql/mssql.class.php
View
22 lib/xmldb/classes/generators/mssql/mssql.class.php
@@ -304,6 +304,28 @@ function getAlterFieldSQL($xmldb_table, $xmldb_field) {
$typechanged = false;
}
+ /// If the new field specs are for integer, lett's be a bit more specific diferentiating
+ /// types of integers. Else, some combinations can cause things like MDL-21868
+ if ($xmldb_field->getType() == XMLDB_TYPE_INTEGER) {
+ if ($xmldb_field->getLength() > 9) { // Convert our new lenghts to detailed meta types
+ $newmssqlinttype = 'I8';
+ } else if ($xmldb_field->getLength() > 4) {
+ $newmssqlinttype = 'I';
+ } else {
+ $newmssqlinttype = 'I2';
+ }
+ if ($metac->type == 'bigint') { // Convert current DB type to detailed meta type (adodb metatype is buggy!)
+ $oldmssqlinttype = 'I8';
+ } else if ($metac->type == 'smallint') {
+ $oldmssqlinttype = 'I2';
+ } else {
+ $oldmssqlinttype = 'I';
+ }
+ if ($newmssqlinttype != $oldmssqlinttype) { // Compare new and old meta types
+ $typechanged = true; // Change in meta type means change in type at all effects
+ }
+ }
+
/// Detect if we are changing the length of the column, not always necessary to drop defaults
/// if only the length changes, but it's safe to do it always
if ($xmldb_field->getLength() == $oldlength) {
Please sign in to comment.
Something went wrong with that request. Please try again.