We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 89ece22 commit ccf0c80Copy full SHA for ccf0c80
2 files changed
tests/WP_SQLite_Driver_Tests.php
@@ -499,6 +499,8 @@ public function testShowCreateTableWithDefaultValues(): void {
499
ID BIGINT PRIMARY KEY AUTO_INCREMENT NOT NULL,
500
no_default VARCHAR(255),
501
default_zero INT DEFAULT 0,
502
+ default_true INT DEFAULT TRUE,
503
+ default_false INT DEFAULT FALSE,
504
default_empty_string VARCHAR(255) DEFAULT '',
505
special_chars_1 TEXT NOT NULL COMMENT '\'',
506
special_chars_2 TEXT NOT NULL COMMENT '''',
@@ -528,6 +530,8 @@ public function testShowCreateTableWithDefaultValues(): void {
528
530
' `ID` bigint NOT NULL AUTO_INCREMENT,',
529
531
' `no_default` varchar(255) DEFAULT NULL,',
532
" `default_zero` int DEFAULT '0',",
533
+ " `default_true` int DEFAULT '1',",
534
+ " `default_false` int DEFAULT '0',",
535
" `default_empty_string` varchar(255) DEFAULT '',",
536
" `special_chars_1` text NOT NULL COMMENT '''',",
537
" `special_chars_2` text NOT NULL COMMENT '''',",
wp-includes/sqlite-ast/class-wp-sqlite-information-schema-builder.php
@@ -2053,15 +2053,35 @@ private function get_column_default( WP_Parser_Node $node ): ?string {
2053
return null;
2054
}
2055
2056
+ /*
2057
+ * [GRAMMAR]
2058
+ * DEFAULT_SYMBOL (
2059
+ * signedLiteral
2060
+ * | NOW_SYMBOL timeFunctionParameters?
2061
+ * | {serverVersion >= 80013}? exprWithParentheses
2062
+ * )
2063
+ */
2064
+
2065
+ // DEFAULT NOW()
2066
if ( $default_attr->has_child_token( WP_MySQL_Lexer::NOW_SYMBOL ) ) {
2067
return 'CURRENT_TIMESTAMP';
2068
2069
- if (
- $default_attr->has_child_node( 'signedLiteral' )
- && null !== $default_attr->get_first_descendant_node( 'nullLiteral' )
- ) {
- return null;
2070
+ // DEFAULT signedLiteral
2071
+ $signed_literal = $default_attr->get_first_child_node( 'signedLiteral' );
2072
+ if ( $signed_literal ) {
2073
+ $literal = $signed_literal->get_first_child_node( 'literal' );
2074
2075
+ // DEFAULT NULL
2076
+ if ( $literal->has_child_node( 'nullLiteral' ) ) {
2077
+ return null;
2078
+ }
2079
2080
+ // DEFAULT TRUE or DEFAULT FALSE
2081
+ if ( $literal->has_child_node( 'boolLiteral' ) ) {
2082
+ $bool_literal = $literal->get_first_child_node( 'boolLiteral' );
2083
+ return $bool_literal->has_child_token( WP_MySQL_Lexer::TRUE_SYMBOL ) ? '1' : '0';
2084
2085
2086
2087
// @TODO: MySQL seems to normalize default values for numeric
0 commit comments