SQLite3Result::fetchArray Doesn't Handle Join Statement Properly
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
When i tried using ( join ) statement for fetching data , sqlite3 tend to overwrite the column name if it appears in the other table
- eg:
table-a
| ID | Name | Foreign_id |
|---|---|---|
| 1 | bar | 2 |
table-b
| ID | Name |
|---|---|
| 2 | foo |
When i try to join them
SELECT * FROM table-a a JOIN table-b b ON(a.foreign_id=b.id)
i get the result as follows
[
array(
'ID' => 2,
'name' => 'foo',
'foreign_id' => 2
)
]
i suggest prefixing the columns names with the table aliases name to clarify and avoid overwriting
So the result would be like this
[
array(
'a.ID' => 1,
'a.name' => 'bar',
'a.Foreign_id' => 2,
'b.ID' => 2,
'b.name' => 'foo'
)
]
thanks in advance
From manual page: https://php.net/sqlite3result.fetcharray
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 with the linked SQLite3Result::fetchArray manual page and reproduce the reported SELECT * JOIN query using the two example tables. Determine the intended handling of duplicate column names and confirm the accepted result shape before changing or testing the behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php, sqlite
- Domain
- database
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100