Assign Default inside analyzeTableColumnsArray
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
1d180c5482
commit
43a864b50f
@ -45,7 +45,6 @@ use function stripcslashes;
|
||||
use function stripslashes;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
use function time;
|
||||
use function trim;
|
||||
|
||||
use const ENT_COMPAT;
|
||||
@ -306,6 +305,7 @@ class InsertEdit
|
||||
* @param ColumnFull $tableColumn description of column in given table
|
||||
* @param string[] $commentsMap comments for every column that has a comment
|
||||
* @param int $columnLength length of the current column taken from field metadata
|
||||
* @param bool $insertMode whether insert mode
|
||||
*
|
||||
* @return mixed[] description of column in given table
|
||||
*/
|
||||
@ -313,6 +313,7 @@ class InsertEdit
|
||||
ColumnFull $tableColumn,
|
||||
array $commentsMap,
|
||||
int $columnLength,
|
||||
bool $insertMode,
|
||||
): array {
|
||||
$column = [
|
||||
'Field' => $tableColumn->field,
|
||||
@ -362,6 +363,15 @@ class InsertEdit
|
||||
// can only occur once per table
|
||||
$column['first_timestamp'] = $column['True_Type'] === 'timestamp';
|
||||
|
||||
if (
|
||||
$tableColumn->type === 'datetime'
|
||||
&& ! $tableColumn->isNull
|
||||
&& $tableColumn->default === null
|
||||
&& $insertMode
|
||||
) {
|
||||
$column['Default'] = date('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
return $column;
|
||||
}
|
||||
|
||||
@ -1725,7 +1735,7 @@ class InsertEdit
|
||||
array $columnMime,
|
||||
string $whereClause,
|
||||
): string {
|
||||
$column = $this->analyzeTableColumnsArray($tableColumn, $commentsMap, $columnLength);
|
||||
$column = $this->analyzeTableColumnsArray($tableColumn, $commentsMap, $columnLength, $insertMode);
|
||||
|
||||
$asIs = false;
|
||||
/** @var string $fieldHashMd5 */
|
||||
@ -1747,10 +1757,6 @@ class InsertEdit
|
||||
// in the name attribute (see bug #1746964 )
|
||||
$columnNameAppendix = $vkey . '[' . $fieldHashMd5 . ']';
|
||||
|
||||
if ($column['Type'] === 'datetime' && $column['Null'] !== 'YES' && ! isset($column['Default']) && $insertMode) {
|
||||
$column['Default'] = date('Y-m-d H:i:s', time());
|
||||
}
|
||||
|
||||
// Get a list of GIS data types.
|
||||
$gisDataTypes = Gis::getDataTypes();
|
||||
|
||||
|
||||
@ -4577,7 +4577,7 @@ parameters:
|
||||
|
||||
-
|
||||
message: "#^Cannot cast mixed to string\\.$#"
|
||||
count: 2
|
||||
count: 3
|
||||
path: libraries/classes/InsertEdit.php
|
||||
|
||||
-
|
||||
@ -4620,6 +4620,11 @@ parameters:
|
||||
count: 1
|
||||
path: libraries/classes/InsertEdit.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$defaultValue of method PhpMyAdmin\\\\InsertEdit\\:\\:getSpecialCharsForInsertingMode\\(\\) expects string\\|null, mixed given\\.$#"
|
||||
count: 1
|
||||
path: libraries/classes/InsertEdit.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$haystack of function mb_strstr expects string, mixed given\\.$#"
|
||||
count: 2
|
||||
|
||||
@ -420,7 +420,7 @@ class InsertEditTest extends AbstractTestCase
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'analyzeTableColumnsArray',
|
||||
[$column, [], -1],
|
||||
[$column, [], -1, false],
|
||||
);
|
||||
|
||||
$this->assertEquals($result['Field_md5'], '4342210df36bf2ff2c4e2a997a6d4089');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user