fix: 修复 H2 建表时表级注释生成 MySQL 内联语法导致建表失败#476
Open
wcpe wants to merge 1 commit into
Open
Conversation
H2 的 createTable 此前把表级注释按 MySQL 方言内联生成在 CREATE TABLE 括号内、PRIMARY KEY 之后() COMMENT='...'),H2 不支持该语法,解析到 PRIMARY KEY 后会报 expected "INDEX, ,, )",导致建表失败、表始终无法创建。 改为在 CREATE TABLE 结束后追加独立的 COMMENT ON TABLE ... IS '...' 语句 (与 PgSQL 等方言一致,且为 H2 合法语法);列级注释保持内联 COMMENT 不变。 新增回归测试实体 H2TableCommentEntity 及 H2QueryTest#testTableCommentDDL, 对内存 H2 实际执行建表 DDL 并断言生成结果,防止回归。
Collaborator
|
感谢我这边看看 |
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.
在使用 Easy-Query 的 H2 数据库迁移功能时,如果实体类通过
@Table(comment = "...")定义了表级注释,当前代码会生成类似 MySQL 的内联注释语法:但 H2 数据库并不支持这种语法(仅在 MySQL 模式下有限支持),导致 H2 执行建表 SQL 时报错,建表失败。