Integer limit, offset and column values raise TypeError in getSqlString() on a strict platform
Mantenedores costumam responder em até 1 dia
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 25/100
Direção de pesquisa
Start with the named call sites in src/Sql/Select.php and src/Sql/AbstractSql.php, then read test/unit/TestAsset/TrustingSql92Platform.php and the existing unit tests that exercise these paths. Check how the expression path handles values before quoting. Done means integer and boolean values are safely quoted and the strict test platform catches non-string arguments; the unit suite passes.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Package Version
0.6.x-dev @ e022af5c
Php Version
8.3, 8.4, 8.5
Database Engine
Any platform whose quoteValue() keeps the string type: Sql92, MySQL, SQLite and PostgreSQL (PDO::quote())
Basic Information
PlatformInterface::quoteValue() takes a string (PlatformInterface.php#L68). Three call sites in strict-typed files pass values that can be integers or booleans:
Select::processLimit()passes$this->limit(Select.php#L522), typedstring|int|null.Select::processOffset()passes$this->offset(Select.php#L540).AbstractSql::resolveColumnValue()passes$column(AbstractSql.php#L445), which can beintorbool. Insert and Update values go through it.
The expression path in the same class already casts: quoteValue((string) $argument->getValue()) (AbstractSql.php#L242).
The unit suite does not catch this because TrustingSql92Platform::quoteValue($value) drops the string type (TrustingSql92Platform.php#L16), so it accepts integers.
Prepared statements are unaffected: those paths bind the value instead of quoting it. The MySQL and SQLite driver SelectDecorators render limit and offset without quoting, so only their non-decorated paths are affected.
Steps to Reproduce
(new Select('t'))->limit(10)->getSqlString($platform)with the MySQL or SQLite driver'sAdapterPlatform, or with PostgreSQL's (which has noSelectDecorator).(new Insert('t'))->values(['c' => 1])rendered withbuildSqlString()on the SQLiteAdapterPlatform.
Expected Behavior
Scalars are cast to string before quoting, as the expression path already does: LIMIT '10' and VALUES ('1').
TrustingSql92Platform::quoteValue() should keep the string type, so the suite fails if a call site passes a non-string again. With that change alone, 6 existing tests error.
Actual behavior?
TypeError: PhpDb\Adapter\Platform\Sql92::quoteValue(): Argument #1 ($value) must be of type string, int given, called in src/Sql/Select.php on line 522
On phpdb-pgsql:
TypeError: PDO::quote(): Argument #1 ($string) must be of type string, int given
Additional Info
The same cast was made on the unmerged sql-platform-refactor branch (a0b63fa4, "Fixed small issue where limit/offset were not cast as strings").
- Linguagem predominante
- PHP
- Estrelas
- 18
- Forks
- 8
- Merge médio
- 6d 11h
- PRs com merge (30d)
- 14
Preparar o ambiente
- Inclui um Dockerfile ou arquivo Docker Compose
- Sem modelo de pull request
- Sem guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de php-db/phpdb
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
RFC
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 66/100
Mantenedores costumam responder em até 1 dia
-
RFC
Dificuldade 5/5 Mais de uma semana Facilidade para iniciantes 38/100
Mantenedores costumam responder em até 1 dia
-
RFC
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
RFC
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 45/100
Mantenedores costumam responder em até 1 dia
Todas as issues de php-db/phpdb
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100
Mantenedores costumam responder em até 1 dia
-
Awaiting Triage bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
Mantenedores costumam responder em até 1 dia
-
freshrss: Unable to update feedsTalvez já em andamento @Stunkymonkey assumiu hoje. Aberta0.kind: bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 65/100
NixOS/nixpkgs#571043 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
product / databases
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
Mantenedores costumam responder em até 1 dia
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
VilnaCRM-Org/user-service#525 ·
Mantenedores costumam responder em até 21 dias