You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
0.5.0 (also 0.6.x-dev @ e037464a and the 0.6.x head)
Php Version
8.4
Database Engine
MySQL
Basic Information
Integer.php#L18-L19 appends ' (' . $options['length'] . ')' to the spec string after Column::getExpressionData() has already added NOT NULL / DEFAULT, so the display width lands after the column attributes and MySQL rejects the statement. It is also the only attribute under Column/* that reaches SQL by string concatenation rather than as an Argument, so the option value goes out raw (Index prefix lengths do the same at Index.php#L53-L54; that one is covered by the literal-slots RFC, #181).
test/unit/Sql/Ddl/Column/IntegerTest.php lines 51-59 assert assertStringContainsString('(11)', $spec) (L58) and so pass on the broken output; lines 61-68 are the companion "excludes length when not set" test.
Document that MySQL deprecated integer display width in 8.0.17 and that the MySQL decorator will drop the attribute (phpdb-mysql#81); other platforms keep rendering it.
Test plan:
new Integer('i', false, null, ['length' => 11]) renders `i` INTEGER(11) NOT NULL; BigInteger/SmallInteger inherit the fix.
setOption('length', 11) is accepted.
IntegerTest asserts the full rendered string, not containment.
No Integer code path concatenates an option value into the spec.
Actual behavior?
CREATETABLE `x` (
`i`INTEGERNOT NULL (11)
)
MySQL 8.4.10 (reproduced on 8.0.46): ERROR 1064 ... near '(11)'.
Additional Info
Reproduced on 0.5.x, e037464a and the 0.6.x head. From an internal DDL audit (not published — the finding is reproduced above). Related: #169.
Package Version
0.5.0 (also
0.6.x-dev@e037464aand the0.6.xhead)Php Version
8.4
Database Engine
MySQL
Basic Information
Integer.php#L18-L19 appends
' (' . $options['length'] . ')'to the spec string afterColumn::getExpressionData()has already addedNOT NULL/DEFAULT, so the display width lands after the column attributes and MySQL rejects the statement. It is also the only attribute underColumn/*that reaches SQL by string concatenation rather than as anArgument, so the option value goes out raw (Indexprefix lengths do the same atIndex.php#L53-L54; that one is covered by the literal-slots RFC, #181).test/unit/Sql/Ddl/Column/IntegerTest.phplines 51-59 assertassertStringContainsString('(11)', $spec)(L58) and so pass on the broken output; lines 61-68 are the companion "excludes length when not set" test.Steps to Reproduce
$table->getSqlString($mysqlPlatform)and execute it.Expected Behavior
MySQL accepts this (with deprecation warning 1681 — display width is deprecated since 8.0.17).
I have a local fix (not pushed) that works, including
BIGINT NULL DEFAULT '7':%s %s(%s) ..., value spliced at index 2 as aLiteralbuilt from anint(cast to string —Argument\Literaltakes a string).intfor the option.setOption()is typedbool|string, sosetOption('length', 11)is aTypeErrorunderstrict_types, while the constructor$optionsarray andsetOptions()take an int without complaint, anddocs/book/sql-ddl/columns.mddocumentslengthasint. WidensetOption()tobool|int|string. Overlaps Untyped array boundaries (AbstractConnection::$connectionParameters, ColumnInterface::getOptions()) cause mixed-* fallout downstream #169.Test plan:
new Integer('i', false, null, ['length' => 11])renders`i` INTEGER(11) NOT NULL;BigInteger/SmallIntegerinherit the fix.setOption('length', 11)is accepted.IntegerTestasserts the full rendered string, not containment.Integercode path concatenates an option value into the spec.Actual behavior?
MySQL 8.4.10 (reproduced on 8.0.46):
ERROR 1064 ... near '(11)'.Additional Info
Reproduced on
0.5.x,e037464aand the0.6.xhead. From an internal DDL audit (not published — the finding is reproduced above). Related: #169.