proceed further with beans

This commit is contained in:
Jan-Niclas Loosen
2025-02-24 10:54:51 +01:00
parent 024e6e73cb
commit 239b81bf0e
10 changed files with 156 additions and 197 deletions

View File

@@ -22,18 +22,19 @@ trait Conditionable
}
protected function addCondition(string $col, string|Operator $operator, mixed $val, string $prefix): self {
$this->schema->requireColumn($col);
$this->schema->reqCol($col);
$info = $this->schema->getCol($col);
// Convert the operator string to a ConditionOperator enum if needed.
if (is_string($operator))
$operator = Operator::fromString($operator);
$columnType = $this->schema->columnType($col);
$castedValue = $columnType->dbCast($val);
$type = $info->type;
$castedVal = $type->dbCast($val);
if (!empty($this->conditions))
$this->conditions[] = $prefix;
$this->conditions[] = "$col " . $operator->toString() . " $castedValue";
$this->conditions[] = "$col " . $operator->toString() . " $castedVal";
return $this;
}