Skip to content

Commit b8ded78

Browse files
committed
Fix: remove broken applyFilterText in DibiFluentMssqlDataSource causing NN-prefix with Dibi 4.1+
The MSSQL-specific override used direct string interpolation for LIKE searches (SQL injection risk, wrong double-quote string delimiters for MSSQL) and called escapeText() in a way that resulted in double N-prefix (NN'...') with Dibi 4.1+ SqlsrvDriver. Removing the override lets the base class implementation handle text filtering correctly via the %%~like~` modifier which invokes the driver's escape method exactly once. Fixes #908
1 parent e7c487d commit b8ded78

File tree

1 file changed

+0
-27
lines changed

1 file changed

+0
-27
lines changed

src/DataSource/DibiFluentMssqlDataSource.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@
55
use Contributte\Datagrid\Exception\DatagridDateTimeHelperException;
66
use Contributte\Datagrid\Filter\FilterDate;
77
use Contributte\Datagrid\Filter\FilterDateRange;
8-
use Contributte\Datagrid\Filter\FilterText;
98
use Contributte\Datagrid\Utils\DateTimeHelper;
109
use Dibi\Fluent;
11-
use Dibi\Helpers;
1210
use Dibi\Result;
1311
use UnexpectedValueException;
1412

@@ -100,29 +98,4 @@ protected function applyFilterDateRange(FilterDateRange $filter): void
10098
}
10199
}
102100

103-
protected function applyFilterText(FilterText $filter): void
104-
{
105-
$condition = $filter->getCondition();
106-
$driver = $this->dataSource->getConnection()->getDriver();
107-
$or = [];
108-
109-
foreach ($condition as $column => $value) {
110-
$column = Helpers::escape($driver, $column, Fluent::Identifier);
111-
112-
if ($filter->isExactSearch()) {
113-
$this->dataSource->where(sprintf('%s = %%s', $column), $value);
114-
115-
continue;
116-
}
117-
118-
$or[] = sprintf('%s LIKE "%%%s%%"', $column, $value);
119-
}
120-
121-
if (count($or) > 1) {
122-
$this->dataSource->where($filter->hasConjunctionSearch() ? '(%and)' : '(%or)', $or);
123-
} else {
124-
$this->dataSource->where($or);
125-
}
126-
}
127-
128101
}

0 commit comments

Comments
 (0)