-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Open
Labels
5.0The issues we want to solve in the 5.0 releaseThe issues we want to solve in the 5.0 releasebugA bug reportA bug reportexternal dependencyThis issue depends on external issue to be resolved.This issue depends on external issue to be resolved.
Description
Questions? Forum: https://phalcon.io/forum or Discord: https://phalcon.io/discord
Describe the bug
Models manager gets a query with the NOT BETWEEN operation in the WHERE clause, it converts the operator to BETWEEN NOT and receives an error on execution.
The issue stems from \Phalcon\Mvc\Model\Query::getExpression(). It resolves the operator to BETWEEN NOT at phalcon/Mvc/Model/Query.zep#L2063-L2069
To Reproduce
- Create a table with a field compatible with the
BETWEENoperator - Write a query with a
NOT BETWEENoperator in theWHEREclause - Execute the query through the
\Phalcon\Mvc\Model\Managerservice - Check the final query that's been executed and see the switch to
BETWEEN NOT
$q = 'SELECT created_at FROM [Models\Orders] WHERE created_at NOT BETWEEN "2025-10-02 00:00:00" AND "2025-10-02 23:59:59"';
try {
$this->modelsManager->executeQuery($q);
} catch (Exception $e) {
$sql = $this->db->getSQLStatement();
}The variable $sql now has the operator changed to BETWEEN NOT
Expected behavior
The operator should remain as NOT BETWEEN, BETWEEN NOT is not a valid usage and fails the execution.
Details
- Phalcon version: 4.x, 5.x
- PHP Version: 7.x, 8.x
- Server: Nginx
Metadata
Metadata
Assignees
Labels
5.0The issues we want to solve in the 5.0 releaseThe issues we want to solve in the 5.0 releasebugA bug reportA bug reportexternal dependencyThis issue depends on external issue to be resolved.This issue depends on external issue to be resolved.