Merge pull request #16924 from shucon/fix_16892
Fixes #16892: current_timestamp() stringified on INSERT for date field
This commit is contained in:
commit
f2d7301559
@ -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()')
|
||||
) {
|
||||
|
||||
@ -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,
|
||||
'<',
|
||||
12,
|
||||
1,
|
||||
'/',
|
||||
'<',
|
||||
"foo\nbar",
|
||||
$extracted_columnspec,
|
||||
false,
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertStringContainsString(
|
||||
'<input type="hidden" name="fields_typeb" value="date">',
|
||||
$result
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user