Drop getEnumSetAndTimestampColumns()
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
9800c3574f
commit
aa689f04f3
@ -329,11 +329,18 @@ class InsertEdit
|
||||
['char', 'varchar'],
|
||||
);
|
||||
|
||||
[
|
||||
$column['pma_type'],
|
||||
$column['wrap'],
|
||||
$column['first_timestamp'],
|
||||
] = $this->getEnumSetAndTimestampColumns($column, $timestampSeen);
|
||||
$column['pma_type'] = match ($column['True_Type']) {
|
||||
'set', 'enum' => $column['True_Type'],
|
||||
default => $column['Type']
|
||||
};
|
||||
|
||||
$column['wrap'] = match ($column['True_Type']) {
|
||||
'set', 'enum' => '',
|
||||
default => ' text-nowrap'
|
||||
};
|
||||
|
||||
// can only occur once per table
|
||||
$column['first_timestamp'] = $column['True_Type'] === 'timestamp' ? ! $timestampSeen : false;
|
||||
|
||||
return $column;
|
||||
}
|
||||
@ -376,29 +383,6 @@ class InsertEdit
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve set, enum, timestamp table columns
|
||||
*
|
||||
* @param mixed[] $column description of column in given table
|
||||
* @param bool $timestampSeen whether a timestamp has been seen
|
||||
*
|
||||
* @return mixed[] $column['pma_type'], $column['wrap'], $column['first_timestamp']
|
||||
* @psalm-return array{0: mixed, 1: string, 2: bool}
|
||||
*/
|
||||
private function getEnumSetAndTimestampColumns(array $column, bool $timestampSeen): array
|
||||
{
|
||||
return match ($column['True_Type']) {
|
||||
'set' => ['set', '', false],
|
||||
'enum' => ['enum', '', false],
|
||||
'timestamp' => [
|
||||
$column['Type'],
|
||||
' text-nowrap',
|
||||
! $timestampSeen, // can only occur once per table
|
||||
],
|
||||
default => [$column['Type'], ' text-nowrap', false],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the nullify code for the null column
|
||||
*
|
||||
|
||||
@ -530,83 +530,6 @@ class InsertEditTest extends AbstractTestCase
|
||||
$this->assertFalse($this->insertEdit->isColumn($column, $types));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getEnumSetAndTimestampColumns
|
||||
*/
|
||||
public function testGetEnumAndTimestampColumns(): void
|
||||
{
|
||||
$column = [];
|
||||
$column['True_Type'] = 'set';
|
||||
$this->assertEquals(
|
||||
['set', '', false],
|
||||
$this->callFunction(
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'getEnumSetAndTimestampColumns',
|
||||
[$column, false],
|
||||
),
|
||||
);
|
||||
|
||||
$column['True_Type'] = 'enum';
|
||||
$this->assertEquals(
|
||||
['enum', '', false],
|
||||
$this->callFunction(
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'getEnumSetAndTimestampColumns',
|
||||
[$column, false],
|
||||
),
|
||||
);
|
||||
|
||||
$column['True_Type'] = 'timestamp';
|
||||
$column['Type'] = 'date';
|
||||
$this->assertEquals(
|
||||
['date', ' text-nowrap', true],
|
||||
$this->callFunction(
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'getEnumSetAndTimestampColumns',
|
||||
[$column, false],
|
||||
),
|
||||
);
|
||||
|
||||
$column['True_Type'] = 'timestamp';
|
||||
$column['Type'] = 'date';
|
||||
$this->assertEquals(
|
||||
['date', ' text-nowrap', false],
|
||||
$this->callFunction(
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'getEnumSetAndTimestampColumns',
|
||||
[$column, true],
|
||||
),
|
||||
);
|
||||
|
||||
$column['True_Type'] = 'SET';
|
||||
$column['Type'] = 'num';
|
||||
$this->assertEquals(
|
||||
['num', ' text-nowrap', false],
|
||||
$this->callFunction(
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'getEnumSetAndTimestampColumns',
|
||||
[$column, false],
|
||||
),
|
||||
);
|
||||
|
||||
$column['True_Type'] = '';
|
||||
$column['Type'] = 'num';
|
||||
$this->assertEquals(
|
||||
['num', ' text-nowrap', false],
|
||||
$this->callFunction(
|
||||
$this->insertEdit,
|
||||
InsertEdit::class,
|
||||
'getEnumSetAndTimestampColumns',
|
||||
[$column, false],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test for getNullifyCodeForNullColumn
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user