Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BETWEEN operator in has() relation filter #128

Open
olaulau opened this issue Feb 29, 2024 · 1 comment
Open

BETWEEN operator in has() relation filter #128

olaulau opened this issue Feb 29, 2024 · 1 comment

Comments

@olaulau
Copy link

olaulau commented Feb 29, 2024

Hi ;

The BETWEEN operator doesn't seem to work in a has() relation filter :

$entity->has("service", ["date BETWEEN ? AND ?", "2024-02-01", "2024-02-29"]); // error
$entity->has("service", ["? <= date AND date <= ?", "2024-02-01", "2024-02-29"]); // works

$result = $entity->find(["pupil_id = ?", 12], []);

I get this error :

500 Internal Server Error
PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[table][rel_field].BETWEEN '2024-02-01' AND '2024-02-29')' at line 1 [[project_path]/vendor/bcosca/fatfree-core/db/sql.php:230]

of course, the same filter directly on the sub-entity work well :
$res2 = $entity2->find(["date BETWEEN ? AND ?", "2024-02-01", "2024-02-29"]);

@ikkez
Copy link
Owner

ikkez commented Mar 6, 2024

I've tested this myself and was not able to reproduce.. it's working fine here.. at least for mysql, postgre and sqlite.. is this a mariaDB only glitch maybe? 🤔

tested with

$author = new AuthorModel();
$author->has('news', ['created_at BETWEEN ? and ?', $time, $time]);
$author->load();   

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants