Merge pull request #16924 from shucon/fix_16892

Fixes #16892: current_timestamp() stringified on INSERT for date field
This commit is contained in:
Maurício Meneghini Fauth 2021-05-27 18:26:41 -03:00 committed by GitHub
commit f2d7301559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 3 deletions

View File

@ -1725,9 +1725,10 @@ class InsertEdit
$html_output .= '<input type="hidden" name="fields_type'
. $column_name_appendix . '" value="timestamp">';
}
if (substr($column['pma_type'], 0, 8) === 'datetime') {
if (substr($column['pma_type'], 0, 4) === 'date') {
$type = substr($column['pma_type'], 0, 8) === 'datetime' ? 'datetime' : 'date';
$html_output .= '<input type="hidden" name="fields_type'
. $column_name_appendix . '" value="datetime">';
. $column_name_appendix . '" value="' . $type . '">';
}
if ($column['True_Type'] === 'bit') {
$html_output .= '<input type="hidden" name="fields_type'
@ -2902,7 +2903,7 @@ class InsertEdit
$current_value = preg_replace('/[^01]/', '0', $current_value);
$current_value = "b'" . $this->dbi->escapeString($current_value)
. "'";
} elseif (! ($type === 'datetime' || $type === 'timestamp')
} elseif (! ($type === 'datetime' || $type === 'timestamp' || $type === 'date')
|| ($current_value !== 'CURRENT_TIMESTAMP'
&& $current_value !== 'current_timestamp()')
) {

View File

@ -2182,6 +2182,35 @@ class InsertEditTest extends AbstractTestCase
'<input type="hidden" name="fields_typeb" value="datetime">',
$result
);
// case 4: (else -> date)
$column['pma_type'] = 'date';
$result = $this->callFunction(
$this->insertEdit,
InsertEdit::class,
'getValueColumnForOtherDatatypes',
[
$column,
'defchar',
'a',
'b',
'c',
22,
'&lt;',
12,
1,
'/',
'&lt;',
"foo\nbar",
$extracted_columnspec,
false,
]
);
$this->assertStringContainsString(
'<input type="hidden" name="fields_typeb" value="date">',
$result
);
}
/**