| @@ -578,8 +578,11 @@ | ||
| 578 | 578 | |
| 579 | 579 | /** |
| 580 | 580 | * Normalize a column definition for comparison. |
| 581 | 581 | * |
| 582 | + * Explicit and implicit nullable forms, including DEFAULT NULL, compare | |
| 583 | + * as the same definition MySQL reports when the default is omitted. | |
| 584 | + * | |
| 582 | 585 | * @param string $definition Column definition. |
| 583 | 586 | * |
| 584 | 587 | * @return string |
| 585 | 588 | */ |
| @@ -612,16 +615,22 @@ | ||
| 612 | 615 | $definition |
| 613 | 616 | ); |
| 614 | 617 | |
| 615 | 618 | // Normalize NULL handling. |
| 619 | + // MySQL reports an explicit NULL default as no default at all. | |
| 620 | + // Remove that default before the nullable marker so both forms compare equal. | |
| 621 | + // Quoted literals are skipped, including escapes and doubled quotes, so a | |
| 622 | + // default value that contains this text is left intact. | |
| 623 | + $quoted = '/(?:\'(?:\'\'|\\\\.|[^\'\\\\])*\'|"(?:\\\\.|""|[^"\\\\])*")(*SKIP)(*F)|'; | |
| 624 | + | |
| 616 | 625 | $definition = preg_replace( |
| 617 | - '/(?<!NOT)\s+NULL\s+DEFAULT\s+NULL\b/', | |
| 626 | + $quoted . '\s+DEFAULT\s+NULL\b/', | |
| 618 | 627 | '', |
| 619 | 628 | $definition |
| 620 | 629 | ); |
| 621 | 630 | |
| 622 | 631 | $definition = preg_replace( |
| 623 | - '/(?<!NOT)\s+NULL\b/', | |
| 632 | + $quoted . '(?<!NOT)\s+NULL\b/', | |
| 624 | 633 | '', |
| 625 | 634 | $definition |
| 626 | 635 | ); |
| 627 | 636 | |