Correctly display column expressions in the table key list
Signed-off-by: William Desportes <williamdes@wdes.fr>
This commit is contained in:
parent
cd4be9ac2c
commit
036f544e7e
@ -254,13 +254,16 @@ class Index
|
||||
*/
|
||||
public function addColumn(array $params)
|
||||
{
|
||||
if (! isset($params['Column_name'])
|
||||
|| strlen($params['Column_name']) <= 0
|
||||
) {
|
||||
$key = $params['Column_name'] ?? $params['Expression'] ?? '';
|
||||
if (isset($params['Expression'])) {
|
||||
// The Expression only does not make the key unique, add a sequence number
|
||||
$key .= $params['Seq_in_index'];
|
||||
}
|
||||
if (strlen($key) <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->columns[$params['Column_name']] = new IndexColumn($params);
|
||||
$this->columns[$key] = new IndexColumn($params);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -364,6 +367,7 @@ class Index
|
||||
if (isset($params['Key_block_size'])) {
|
||||
$this->keyBlockSize = $params['Key_block_size'];
|
||||
}
|
||||
|
||||
if (! isset($params['Parser'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -48,6 +48,13 @@ class IndexColumn
|
||||
*/
|
||||
private $cardinality = null;
|
||||
|
||||
/**
|
||||
* If the Index uses an expression and not a name
|
||||
*
|
||||
* @var string|null
|
||||
*/
|
||||
private $expression = null;
|
||||
|
||||
/**
|
||||
* @param array $params an array containing the parameters of the index column
|
||||
*/
|
||||
@ -56,6 +63,22 @@ class IndexColumn
|
||||
$this->set($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the Index has an expression
|
||||
*/
|
||||
public function hasExpression(): bool
|
||||
{
|
||||
return $this->expression !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Index expression if it has one
|
||||
*/
|
||||
public function getExpression(): ?string
|
||||
{
|
||||
return $this->expression;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets parameters of the index column
|
||||
*
|
||||
@ -80,6 +103,9 @@ class IndexColumn
|
||||
if (isset($params['Sub_part'])) {
|
||||
$this->subPart = $params['Sub_part'];
|
||||
}
|
||||
if (isset($params['Expression'])) {
|
||||
$this->expression = $params['Expression'];
|
||||
}
|
||||
if (! isset($params['Null'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@
|
||||
<tr class="noclick">
|
||||
{% endif %}
|
||||
<td>
|
||||
{{ column.getName() }}
|
||||
{% if column.hasExpression() %}{{ column.getExpression() }}{% else %}{{ column.getName() }}{% endif %}
|
||||
{% if column.getSubPart() is not empty %}
|
||||
({{ column.getSubPart() }})
|
||||
{% endif %}
|
||||
|
||||
@ -475,7 +475,7 @@
|
||||
<tr class="noclick">
|
||||
{% endif %}
|
||||
<td>
|
||||
{{ column.getName() }}
|
||||
{% if column.hasExpression() %}{{ column.getExpression() }}{% else %}{{ column.getName() }}{% endif %}
|
||||
{% if column.getSubPart() is not empty %}
|
||||
({{ column.getSubPart() }})
|
||||
{% endif %}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user