contributte / contributte/datagrid

SQL filter

Open
#552 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
296
Forks
215
PR merge metrics
No merged PRs in 30d

Description

In some situation I needed more complicated filter and hence the method in DibiFluentDataSource.php

`
/**
* Filter by keyword
* @param Filter\FilterText $filter
* @return void
*/
public function applyFilterText(Filter\FilterText $filter)
{
$condition = $filter->getCondition();
$driver = $this->data_source->getConnection()->getDriver();
$or = [];

	foreach ($condition as $column => $value) {
                    if (class_exists(Dibi\Helpers::class) === TRUE) {

I modified for
/**
* Filter by keyword
* @param Filter\FilterText $filter
* @return void
*/
public function applyFilterText(Filter\FilterText $filter)
{
$condition = $filter->getCondition();
$driver = $this->data_source->getConnection()->getDriver();
$or = [];

	foreach ($condition as $column => $value) {
                    if (substr($column, 0 ,4) == '%sql') {
                            $column = substr($column, 4);
                    } elseif (class_exists(Dibi\Helpers::class) === TRUE) {

`

Which allows in the function
addFilterText(column_name, text, [search_column_names])
parameters search_column_names in form '%sql.....' and sql expression that is verified against the text

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in DibiFluentDataSource.php at applyFilterText() and inspect how Filter\FilterText conditions are processed. Trace the existing addFilterText(column_name, text, [search_column_names]) usage and the proposed %sql-prefixed expressions. Done means the SQL expressions are accepted and checked against the text without breaking the existing filter behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
backend, databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.