Compare commits

..

2 Commits

Author SHA1 Message Date
kj
ce03bdb27d fix(model): Fix postgresql search. 2025-10-27 15:16:54 -03:00
kj
b24598b118 fix(sqlite): Correct base table for RIGHT JOIN conversion 2025-10-27 15:15:45 -03:00
2 changed files with 8 additions and 5 deletions

View File

@@ -103,7 +103,7 @@ En la siguiente tabla se encuentra la lista de estados de los gestores de bases
|------------------+---------------+---------+------------| |------------------+---------------+---------+------------|
| getById | ok | ok | ok | | getById | ok | ok | ok |
|------------------+---------------+---------+------------| |------------------+---------------+---------+------------|
| search | ok | ok | error | | search | ok | ok | ok |
|------------------+---------------+---------+------------| |------------------+---------------+---------+------------|
| get | ok | ok | ok | | get | ok | ok | ok |
|------------------+---------------+---------+------------| |------------------+---------------+---------+------------|

View File

@@ -822,7 +822,10 @@ class Model
} }
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') { if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') {
return static::leftJoin($table, $columnB, $operatorOrColumnB, $columnA); $currentTable = empty(static::$querySelect['from']) ?
static::table() : static::$querySelect['from'];
static::$querySelect['from'] = $table;
return static::leftJoin($currentTable, $columnB, $operatorOrColumnB, $columnA);
} }
static::$querySelect['rightJoin'] .= ' RIGHT JOIN ' . $table . ' ON ' . "$columnA$operatorOrColumnB$columnB"; static::$querySelect['rightJoin'] .= ' RIGHT JOIN ' . $table . ' ON ' . "$columnA$operatorOrColumnB$columnB";
@@ -1037,13 +1040,13 @@ class Model
$search = static::bind($search); $search = static::bind($search);
$where = []; $where = [];
if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'sqlite') { if (static::db()->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
foreach ($in as $row) { foreach ($in as $row) {
$where[] = "$row LIKE '%' || $search || '%'"; $where[] = "$row LIKE CONCAT('%', $search, '%')";
} }
} else { } else {
foreach ($in as $row) { foreach ($in as $row) {
$where[] = "$row LIKE CONCAT('%', $search, '%')"; $where[] = "CAST($row AS TEXT) LIKE '%' || $search || '%'";
} }
} }