Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Integer limit, offset and column values raise TypeError in getSqlString() on a strict platform

オープン
#205 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@simon-mundy がすでに取り組んでいます。

2026年10月5日 から。

  • #222 @simon-mundy による — オープン

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
php, sql
領域
database

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

bug
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), typed string|int|null.
  • Select::processOffset() passes $this->offset (Select.php#L540).
  • AbstractSql::resolveColumnValue() passes $column (AbstractSql.php#L445), which can be int or bool. 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
  1. (new Select('t'))->limit(10)->getSqlString($platform) with the MySQL or SQLite driver's AdapterPlatform, or with PostgreSQL's (which has no SelectDecorator).
  2. (new Insert('t'))->values(['c' => 1]) rendered with buildSqlString() on the SQLite AdapterPlatform.
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").

主要言語
PHP
スター
18
フォーク
8
平均マージ
6日 11時間
マージ済み PR(30日)
14

環境構築

  • Dockerfile または Docker Compose ファイルあり
  • プルリクエストのテンプレートなし
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

php-db/phpdb のほかの issue

php-db/phpdb の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。