codeconsole commented on PR #16322: URL: https://github.com/apache/grails-core/pull/16322#issuecomment-5669832773
Thanks. All addressed in `0a93f8d`, `07afd38` and `0542112`. **Model binding: converts now, but refuses a conversion that changes the value.** I took the coercion, with one guard. `castToType` on its own reproduces the truncation #16323 exists to remove. On the Groovy 5.1 jar, `Integer ← 3_000_000_000L` gives `-1294967296`, `Integer ← Long.MAX_VALUE` gives `-1`, and `Integer ← 42.9G` gives `42`, all silently. So `GroovyPage` converts with `castToType` and throws, naming the field and both types, when a numeric value doesn't survive the conversion (checked as `BigInteger` for whole numbers, `BigDecimal` otherwise). `Integer ← 42L`, `Integer ← 42.0G` and GString → String convert. A `Date` still fails, with the `GroovyCastException` as cause. The mismatch spec now uses `Integer`/`Date`, plus data-driven conversion and lossy rows. Without the guard, exactly the four lossy rows fail. **Docs:** one paragraph under *Declaring the Model* in `gspStaticCompilation.adoc` states the conversion and the lossy failure. **Tests:** - `gsp-compile-static` stages the profile welcome page beside its own pages for `compileGroovyPages`. It compiles, and the page class extends `CompileStaticGroovyPage`. - `ScaffoldedIndexViewModelSpec` expands `scaffolding/index.gsp` with `ModelBuilder`, the way dynamic scaffolding does, and renders its model declaration with `3`, `3L` and `3_000_000_000L`. The last row is a count the old `Integer` declaration can no longer hold. **Nits:** the description now says three closures fail, with the listener sort kept for consistency. The `scaffolding.adoc` model names are fixed too, since it's the page a reader would check for the count field. Verified: `GspCompileStaticSpec` (40 tests), `ScaffoldedIndexViewModelSpec`, `gsp-compile-static:compileGroovyPages` and `grails-gsp-core:checkstyleMain`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
