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

Error after upgrade to CI4.4.0 + CI4-Datatable 0.6.1 #39

Open
darbor opened this issue Sep 20, 2023 · 0 comments
Open

Error after upgrade to CI4.4.0 + CI4-Datatable 0.6.1 #39

darbor opened this issue Sep 20, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@darbor
Copy link

darbor commented Sep 20, 2023

`$builder = $this->worktimes->builder('worktimes w')
->select('w.id,
w.created_at,
w.work_at,
w.time_at,
CASE
WHEN w.object = "firms" THEN "Firma"
WHEN w.object = "persons" THEN "Osoba"
END as object,
CASE
WHEN w.object = "firms" THEN f.firmname
WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname)
END as objectname,
c.name,
w.note', false)
->join('firms f', 'f.id = w.object_id', 'left outer')
->join('persons p', 'p.id = w.object_id', 'left outer')
->join('categories c', 'c.id = w.categorie_id')
->where('w.deleted_at', null);

$return = DataTable::of($builder)
->setSearchableColumns(['w.created_at', 'w.updated_at', 'w.work_at', 'w.time_at', 'w.note', 'f.firmname', 'p.firstname', 'p.lastname', 'c.name'])

->edit('time_at', function ($row) {
return "

$row->time_at
";
})
->toJson();`

Error:

{
"title": "ErrorException",
"type": "ErrorException",
"code": 500,
"message": "Undefined array key 4",
"file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php",
"line": 308,
"trace": [
{
"file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php",
"line": 308,
"function": "errorHandler",
"class": "CodeIgniter\Debug\Exceptions",
"type": "->",
"args": [
2,
"Undefined array key 4",
"/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php",
308
]
},
{
"file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTableColumnDefs.php",
"line": 17,
"function": "initFromBuilder",
"class": "Hermawan\DataTables\DataTableColumnDefs",
"type": "->",
"args": [
{
"QBGroupBy": [],
"QBOrderBy": [],
"QBNoEscape": [
false
]
}
]
},
{
"file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTable.php",
"line": 35,
"function": "__construct",
"class": "Hermawan\DataTables\DataTableColumnDefs",
"type": "->",
"args": [
{
"QBGroupBy": [],
"QBOrderBy": [],
"QBNoEscape": [
false
]
}
]
},
{
"file": "/var/www/html/ci/vendor/hermawan/codeigniter4-datatables/src/DataTable.php",
"line": 46,
"function": "__construct",
"class": "Hermawan\DataTables\DataTable",
"type": "->",
"args": [
{
"QBGroupBy": [],
"QBOrderBy": [],
"QBNoEscape": [
false
]
}
]
},

When remove :
CASE WHEN w.object = "firms" THEN "Firma" WHEN w.object = "persons" THEN "Osoba" END as object, CASE WHEN w.object = "firms" THEN f.firmname WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname) END as objectname,

Query is ok

After upgrade form 4.2.1 > 4.2.2 i have error durign response .

====

finaly i change all CASE to separate select:
->select("CASE
WHEN w.object = "firms" THEN "Firma"
WHEN w.object = "persons" THEN "Osoba"
END as object", false)
->select("CASE
WHEN w.object = "firms" THEN f.firmname
WHEN w.object = "persons" THEN CONCAT(p.lastname, " ", p.firstname)
END as objectname", false);

and work ok

@darbor darbor added the bug Something isn't working label Sep 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant