btlqql opened a new pull request, #5331:
URL: https://github.com/apache/rocketmq-dashboard/pull/5331
### Which Issue(s) This PR Fixes
- Fixes #5131
### Brief Description
The canonical schema declares the metric snapshot column as `` `value` ``
(`server/src/main/resources/db/schema.sql:338`), but `RmqMetricSnapshot.value`
(`server/src/main/java/org/apache/rocketmq/studio/persistence/entity/RmqMetricSnapshot.java:38`)
carried no explicit MyBatis-Plus column mapping, so the generated SQL used the
bare identifier `value`. `VALUE` is a reserved word in H2, which the `dev`
profile runs in MySQL compatibility mode, so every metric snapshot insert and
select failed with `JdbcSQLSyntaxErrorException [42001-240]`.
The fix adds `@TableField("`value`")` to that single field, so the generated
SQL now writes the column exactly as the schema declares it. The
backtick-quoted form is accepted by MySQL as well, so no schema or collection
behaviour changes.
### How Did You Test This Change?
New test `MetricSnapshotValueColumnMappingTest` runs the real
`db/schema.sql` against H2 2.4.240 in MySQL compatibility mode, then
round-trips `RmqMetricSnapshot` rows through `RmqMetricSnapshotMapper` (single
insert + select, and a two-row batch + select).
Before the fix — the unquoted reserved identifier reaches H2:
```
$ cd server && mvn -B -ntp test -Dtest=MetricSnapshotValueColumnMappingTest
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[ERROR]
MetricSnapshotValueColumnMappingTest.metricSnapshotValueRoundTripsThroughTheSchemaTest:52
? Persistence
### Error updating database. Cause:
org.h2.jdbc.JdbcSQLSyntaxErrorException: Syntax error in SQL statement "INSERT
INTO rmq_metric_snapshot ( instance_id, metric_key, domain, labels_hash,
labels_json, [*]value, availability, collected_at ) VALUES ( ?, ?, ?, ?, ?,
?, ?, ? )"; expected "identifier"; SQL statement:
INSERT INTO rmq_metric_snapshot ( instance_id, metric_key, domain,
labels_hash, labels_json, value, availability, collected_at ) VALUES ( ?, ?,
?, ?, ?, ?, ?, ? ) [42001-240]
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0
[INFO] BUILD FAILURE
```
After the fix:
```
$ cd server && mvn -B -ntp test -Dtest=MetricSnapshotValueColumnMappingTest
[INFO] You have 0 Checkstyle violations.
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.421
s -- in
org.apache.rocketmq.studio.persistence.MetricSnapshotValueColumnMappingTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0
[INFO] BUILD SUCCESS
```
### Checklist
- [x] One coherent change; unrelated modifications are not bundled in
- [x] Commit subject follows Conventional Commits
- [x] Tests added or updated for non-trivial changes
- [x] New UI text has both Chinese and English entries under `web/src/i18n/`
— not applicable, no UI text
- [x] Architecture constraints stay green (`mvn test` runs the ArchUnit
checks) — the changed production files are one entity annotation, no new
package or dependency edge
- [x] New source files carry the ASF license header
- [x] Documentation touched where behaviour changed (README / `docs/` /
in-app help) — not applicable, the schema and its documentation are unchanged;
the entity now matches the existing schema
--
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]