diff --git a/src/ActiveRecord.php b/src/ActiveRecord.php index 1d7d787..1d9bc28 100644 --- a/src/ActiveRecord.php +++ b/src/ActiveRecord.php @@ -716,8 +716,11 @@ public function addCondition(string $field, string $operator, $value, string $de $value = $this->filterParam($value); } $name = strtolower($name); + + // skip adding the `table.` prefix if it's already there or a function is being supplied. + $skip_table_prefix = (strpos($field, '.') !== false || strpos($field, '(') !== false); $expressions = new Expressions([ - 'source' => ('where' === $name ? $this->table . '.' : '') . $field, + 'source' => ('where' === $name && $skip_table_prefix === false ? $this->table . '.' : '') . $field, 'operator' => $operator, 'target' => ( is_array($value)