Sql::orderBy doesn't quote columns
Open
Nobody has claimed this yet.
Enhancement
Support
- Dominant language
- PHP
- Stars
- 237
- Forks
- 32
- PR merge metrics
- No merged PRs in 30d
Description
I've this query which does not quote columns and then mysql retrieve an incorrect order. The table has timestamp column
$mapper->news->fetchAll(Sql::orderBy('timestamp', 'id')->desc()->limit($initial, $pageSize))
Resulting query:
SELECT news.* FROM news ORDER BY timestamp, id DESC LIMIT 0, 200
expected:
SELECT news.* FROM news ORDER BY `timestamp`, `id` DESC LIMIT 0, 200
Is there a way to instruct Sql to quote columns?
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 at the Sql::orderBy entry point mentioned in the report and reproduce the shown query against MySQL, focusing on how column names are rendered. Confirm the behavior with a regression test or equivalent query check; done means orderBy produces the expected quoted identifiers for timestamp and id.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- mysql, php
- Domain
- database
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100