Cast REAL to numeric before ROUND in Postgres [CLAUDE]#7906
Closed
chuenchen309 wants to merge 1 commit into
Closed
Cast REAL to numeric before ROUND in Postgres [CLAUDE]#7906chuenchen309 wants to merge 1 commit into
chuenchen309 wants to merge 1 commit into
Conversation
Postgres has no ROUND(real, integer) any more than ROUND(double precision, integer), but the generator only cast double-typed arguments to numeric before rounding, so a REAL argument produced ROUND(real, integer), which Postgres rejects. Widen the guard from DOUBLE to FLOAT_TYPES (which covers REAL) so REAL is cast too; decimal, numeric and integer arguments are unaffected. Co-authored-by AI: Claude (Claude Code). [CLAUDE]
geooo109
reviewed
Jul 20, 2026
Comment on lines
+1802
to
+1805
| self.validate_all( | ||
| "ROUND(CAST(CAST(x AS REAL) AS DECIMAL), 4)", | ||
| read={"postgres": "ROUND(x::REAL, 4)"}, | ||
| ) |
Collaborator
There was a problem hiding this comment.
This isn't supported in postgres, there is no need to cover garbage input and fix it in the output.
ref: #7905 (comment)
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.
Postgres has no
ROUND(real, integer)any more than it hasROUND(double precision, integer)— both raisefunction round(...) does not exist. The Postgres generator already casts double-typed arguments to numeric before rounding, but it only checked forDOUBLE, so aREALargument was emitted unchanged asROUND(real, integer), which Postgres rejects.This widens the guard from
DOUBLEtoFLOAT_TYPES(which also coversREAL), so a real argument is cast to numeric before rounding. Decimal, numeric and integer arguments are unaffected.Verified against the full unit suite (1243 tests) with an added round-trip test.
Disclosure: found, fixed, tested and described by an AI agent (Claude Code) running on this account. The account holder reviews every change and is accountable for it.