MedicOneSystems / MedicOneSystems/livewire-datatables
Postgres SQL error with COALESCE when using callback
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 1.2k
- Forks
- 257
- PR merge metrics
- No merged PRs in 30d
Description
I am using a callback like so:
Column::callback(['name', 'id'], function ($name, $id) {
return view('livewire-partials.something')->with([
'name' => $name,
'id' => $id,
]);
}),
This causes an SQL error (with PostgreSQL at least): ERROR: invalid input syntax for integer: ""
When looking at the query:
select CONCAT_WS('|**lwdt**|' ,COALESCE(table.name, ''), COALESCE(table.id, '')) AS "callback_2408452824" from "table"
It seems that COALESCE can't handle different data types well. When casting to text, like so, COALESCE(table.id::text, ''), the query works fine.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing how Column::callback builds the PostgreSQL query shown in the issue, especially the COALESCE expressions used for callback columns. Reproduce the failure with PostgreSQL and confirm that the generated query handles the integer id without the invalid input syntax error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php, postgresql
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100