Skip to content

Commit

Permalink
chore: Move meta column identifiers to constants
Browse files Browse the repository at this point in the history
Signed-off-by: Julius Härtl <jus@bitgrid.net>
  • Loading branch information
juliusknorr committed Apr 25, 2024
1 parent a026d6e commit 8d33235
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
7 changes: 7 additions & 0 deletions lib/Db/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@
* @method setDatetimeDefault(?string $datetimeDefault)
*/
class Column extends Entity implements JsonSerializable {
// Meta column types
public const TYPE_META_ID = -1;
public const TYPE_META_CREATED = -2;
public const TYPE_META_CREATED_AT = -3;
public const TYPE_META_UPDATED = -4;
public const TYPE_META_UPDATED_AT = -5;

public const TYPE_SELECTION = 'selection';
public const TYPE_TEXT = 'text';
public const TYPE_NUMBER = 'number';
Expand Down
10 changes: 5 additions & 5 deletions lib/Db/Row2Mapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,19 +407,19 @@ private function getMetaFilterExpression(IQueryBuilder $qb, int $columnId, strin
$qb2->from('tables_row_sleeves');

switch ($columnId) {
case -1: // row ID
case Column::TYPE_META_ID:
$qb2->where($this->getSqlOperator($operator, $qb, 'id', $value, IQueryBuilder::PARAM_INT));
break;
case -2: // created by
case Column::TYPE_META_CREATED:
$qb2->where($this->getSqlOperator($operator, $qb, 'created_by', $value, IQueryBuilder::PARAM_STR));
break;
case -3: // created at
case Column::TYPE_META_CREATED_AT:
$qb2->where($this->getSqlOperator($operator, $qb, 'created_at', $value, IQueryBuilder::PARAM_DATE));
break;
case -4: // last edit by
case Column::TYPE_META_UPDATED:
$qb2->where($this->getSqlOperator($operator, $qb, 'last_edit_by', $value, IQueryBuilder::PARAM_STR));
break;
case -5: // last edit at
case Column::TYPE_META_UPDATED_AT:
$qb2->where($this->getSqlOperator($operator, $qb, 'last_edit_at', $value, IQueryBuilder::PARAM_DATE));
break;
}
Expand Down

0 comments on commit 8d33235

Please sign in to comment.