Changeset 47184
- Timestamp:
- 02/05/2020 04:28:13 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/dbdelta.php
r47122 r47184 16 16 17 17 /** 18 * Display width for BIGINT data type. 19 * 20 * Prior to MySQL 8.0.17, default width of 20 digits was used: BIGINT(20). 21 * Since MySQL 8.0.17, display width for integer data types is no longer supported. 22 */ 23 protected $bigint_display_width = ''; 24 25 /** 18 26 * Make sure the upgrade code is loaded before the tests are run. 19 27 */ … … 31 39 32 40 global $wpdb; 41 42 $db_version = $wpdb->db_version(); 43 44 if ( version_compare( $db_version, '8.0.17', '<' ) ) { 45 // Prior to MySQL 8.0.17, default width of 20 digits was used: BIGINT(20). 46 $this->bigint_display_width = '(20)'; 47 } 33 48 34 49 // Forcing MyISAM, because InnoDB only started supporting FULLTEXT indexes in MySQL 5.7. … … 37 52 " 38 53 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 39 id bigint (20)NOT NULL AUTO_INCREMENT,54 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 40 55 column_1 varchar(255) NOT NULL, 41 56 column_2 text, … … 79 94 $updates = dbDelta( 80 95 "CREATE TABLE {$wpdb->prefix}dbdelta_create_test ( 81 id bigint (20)NOT NULL AUTO_INCREMENT,96 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 82 97 column_1 varchar(255) NOT NULL, 83 98 PRIMARY KEY (id) … … 114 129 " 115 130 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 116 id bigint (20)NOT NULL AUTO_INCREMENT,131 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 117 132 column_1 varchar(255) NOT NULL, 118 133 PRIMARY KEY (id), … … 133 148 global $wpdb; 134 149 135 // id: bigint (20)=> int(11)150 // id: bigint => int(11) 136 151 $updates = dbDelta( 137 152 " … … 149 164 array( 150 165 "{$wpdb->prefix}dbdelta_test.id" 151 => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint (20)to int(11)",166 => "Changed type of {$wpdb->prefix}dbdelta_test.id from bigint{$this->bigint_display_width} to int(11)", 152 167 ), 153 168 $updates … … 165 180 " 166 181 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 167 id bigint (20)NOT NULL AUTO_INCREMENT,182 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 168 183 column_1 varchar(255) NOT NULL, 169 184 extra_col longtext, … … 200 215 " 201 216 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 202 id bigint (20)NOT NULL AUTO_INCREMENT,217 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 203 218 PRIMARY KEY (id), 204 219 KEY key_1 (column_1($this->max_index_length)), … … 224 239 " 225 240 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 226 id bigint (20)NOT NULL AUTO_INCREMENT,241 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 227 242 column_1 varchar(255) NOT NULL, 228 243 extra_col longtext, … … 276 291 " 277 292 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 278 id bigint (20)NOT NULL AUTO_INCREMENT,293 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 279 294 column_1 varchar(255) NOT NULL, 280 295 PRIMARY KEY (id), … … 421 436 " 422 437 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 423 id bigint (20)NOT NULL AUTO_INCREMENT,438 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 424 439 column_1 varchar(255) NOT NULL, 425 440 column_2 tinytext, … … 446 461 " 447 462 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 448 id bigint (20)NOT NULL AUTO_INCREMENT,463 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 449 464 column_1 varchar(255) NOT NULL, 450 465 column_2 text, … … 471 486 " 472 487 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 473 id bigint (20)NOT NULL AUTO_INCREMENT,488 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 474 489 column_1 varchar(255) NOT NULL, 475 490 column_2 bigtext, … … 502 517 " 503 518 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 504 id bigint (20)NOT NULL AUTO_INCREMENT,519 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 505 520 column_1 varchar(255) NOT NULL, 506 521 column_2 text, … … 532 547 $schema = " 533 548 CREATE TABLE {$wpdb->prefix}dbdelta_test2 ( 534 `id` bigint (20)NOT NULL AUTO_INCREMENT,549 `id` bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 535 550 `column_1` varchar(255) NOT NULL, 536 551 PRIMARY KEY (id), … … 555 570 global $wpdb; 556 571 557 if ( version_compare( $wpdb->db_version(), '5.4', '<' ) ) { 572 $db_version = $wpdb->db_version(); 573 574 if ( version_compare( $db_version, '5.4', '<' ) ) { 558 575 $this->markTestSkipped( 'Spatial indices require MySQL 5.4 and above.' ); 559 576 } 560 577 578 $geomcollection_name = 'geomcollection'; 579 580 if ( version_compare( $db_version, '8.0.11', '<' ) ) { 581 // Prior to MySQL 8.0.11, GeometryCollection data type name was used. 582 $geomcollection_name = 'geometrycollection'; 583 } 584 561 585 $schema = 562 586 " 563 587 CREATE TABLE {$wpdb->prefix}spatial_index_test ( 564 non_spatial bigint (20)unsigned NOT NULL,565 spatial_value geometrycollectionNOT NULL,588 non_spatial bigint{$this->bigint_display_width} unsigned NOT NULL, 589 spatial_value {$geomcollection_name} NOT NULL, 566 590 KEY non_spatial (non_spatial), 567 591 SPATIAL KEY spatial_key (spatial_value) … … 579 603 " 580 604 CREATE TABLE {$wpdb->prefix}spatial_index_test ( 581 non_spatial bigint (20)unsigned NOT NULL,582 spatial_value geometrycollectionNOT NULL,583 spatial_value2 geometrycollectionNOT NULL,605 non_spatial bigint{$this->bigint_display_width} unsigned NOT NULL, 606 spatial_value {$geomcollection_name} NOT NULL, 607 spatial_value2 {$geomcollection_name} NOT NULL, 584 608 KEY non_spatial (non_spatial), 585 609 SPATIAL KEY spatial_key (spatial_value) … … 609 633 $schema = " 610 634 CREATE TABLE {$wpdb->prefix}dbdelta_test2 ( 611 `id` bigint (20)NOT NULL AUTO_INCREMENT,635 `id` bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 612 636 `references` varchar(255) NOT NULL, 613 637 PRIMARY KEY (`id`), … … 639 663 " 640 664 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 641 id bigint (20)NOT NULL AUTO_INCREMENT,665 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 642 666 column_1 varchar(255) NOT NULL, 643 667 column_2 text, … … 683 707 $schema = " 684 708 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 685 id bigint (20)NOT NULL AUTO_INCREMENT,709 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 686 710 column_1 varchar(255) NOT NULL, 687 711 column_2 text, … … 722 746 " 723 747 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 724 id bigint (20)NOT NULL AUTO_INCREMENT,748 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 725 749 column_1 varchar(255) NOT NULL, 726 750 column_2 text, … … 745 769 $schema = " 746 770 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 747 id bigint (20)NOT NULL AUTO_INCREMENT,771 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 748 772 column_1 varchar(255) NOT NULL, 749 773 column_2 text, … … 780 804 " 781 805 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 782 id bigint (20)NOT NULL AUTO_INCREMENT,806 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 783 807 column_1 varchar(255) NOT NULL, 784 808 column_2 text, … … 804 828 " 805 829 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 806 id bigint (20)NOT NULL AUTO_INCREMENT,830 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 807 831 column_1 varchar(255) NOT NULL, 808 832 column_2 text, … … 828 852 " 829 853 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 830 id bigint (20)NOT NULL AUTO_INCREMENT,854 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 831 855 column_1 varchar(255) NOT NULL, 832 856 column_2 text, … … 852 876 " 853 877 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 854 id bigint (20)NOT NULL AUTO_INCREMENT,878 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 855 879 column_1 varchar(255) NOT NULL, 856 880 column_2 text, … … 876 900 " 877 901 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 878 id bigint (20)NOT NULL AUTO_INCREMENT,902 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 879 903 column_1 varchar(255) NOT NULL, 880 904 column_2 text, … … 901 925 " 902 926 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 903 id bigint (20)NOT NULL AUTO_INCREMENT,927 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 904 928 column_1 varchar(255) NOT NULL, 905 929 column_2 text, … … 926 950 " 927 951 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 928 id bigint (20)NOT NULL AUTO_INCREMENT,952 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 929 953 column_1 varchar(255) NOT NULL, 930 954 column_2 text, … … 949 973 " 950 974 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 951 id bigint (20)NOT NULL AUTO_INCREMENT,975 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 952 976 column_1 varchar(255) NOT NULL, 953 977 column_2 text, … … 967 991 " 968 992 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 969 id bigint (20)NOT NULL AUTO_INCREMENT,993 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 970 994 column_1 varchar(255) NOT NULL, 971 995 column_2 text, … … 985 1009 " 986 1010 CREATE TABLE {$wpdb->prefix}dbdelta_test ( 987 id bigint (20)NOT NULL AUTO_INCREMENT,1011 id bigint{$this->bigint_display_width} NOT NULL AUTO_INCREMENT, 988 1012 column_1 varchar(255) NOT NULL, 989 1013 column_2 text,
Note: See TracChangeset
for help on using the changeset viewer.