db: make floatToSql() a public static helper on DB - #16
Merged
Conversation
- moved from ConnectionInternals to DBInternals, next to assertIdentifier(), marked @internal the same way - escape(), escapef(), and the placeholder converter now call DB::floatToSql() - same output and same NAN/INF exception as before - new FloatToSqlTest pins the literal spelling and the exceptions Lets CMS Builder's backup dumper format floats exactly the way ZenDB does.
It formats a value for SQL, so it belongs with escape(), escapef(), and escapeCSV() rather than under Validation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes
floatToSql()callable from outside ZenDB so CMS Builder's backup dumper can format a PHP float as a SQL literal exactly the way ZenDB does.Changes
floatToSql()moves from the ConnectionInternals trait to DBInternals, next toassertIdentifier(), aspublic static function floatToSql(float $value, string $context = 'value'): string, marked@internalthe same way. Body and docblock are unchanged.escape(),escapef(), the placeholder value converter) now callDB::floatToSql().is_finiteandvar_exportadded to DBInternals,is_finitedropped from ConnectionInternals where nothing else used it.InvalidArgumentExceptionfor NAN and INF.docs/ai-reference.mdsince it stays@internal.Tests
New
tests/ValueTypes/FloatToSqlTest.phpcovers:0.10.11234567890.12345671234567890.12345670.3 - 0.10.199999999999999981.0E+201.0E+20-2.5E-7-2.5E-73.03.0-0.0-0.0NAN, INF, and -INF throw
InvalidArgumentExceptionwith the context word in the message.Full suite: 1561 tests, 4285 assertions, 4 skipped (all environmental: no time_zone tables, SSL refused,
mysqli::quote_stringneeds PHP 8.6, functional indexes need MySQL 8.0.13+). All existing escape, escapef, numeric, and placeholder float tests pass unchanged.