We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mybatis-plus-generator 3.5.10.1
本 issue 与 #6682 一致
从以前的版本升级上来后,运行这个 generator 生成的 entity 注解的先后顺序不统一,会导致git历史出现很多修改。
如图,左侧为 3.5.9 版本生成的 entity(先 @Schema,后 @TableField),右侧为 3.5.10.1 版本生成的(@Schema,@TableField 前后顺序不一致)。
个人认为,此处排序应该
@Schema
@TableField
从结果来看,似乎当前是按照整行代码的长度进行排序,就导致了@Schema 与 @TableField 两者哪一行短哪行就在前面。
试图阅读了一下源码,找到了这里(但这里似乎是针对entity类名上的注解排序,暂时还没有找到具体entity字段的注解排序的逻辑): https://github.com/baomidou/mybatis-plus/blame/c9ec9569230b1ed34ab44d992107d8c1b7c588cd/mybatis-plus-generator/src/main/java/com/baomidou/mybatisplus/generator/config/builder/Entity.java#L428
The text was updated successfully, but these errors were encountered:
以字符长度
Sorry, something went wrong.
@nieqiurong 是的,就是说目前以字符长度或许不是最佳的排序方式。
按照注解的首字母 A-Z 排序,或者按照注解的注解名(不包含后面括号参数部分)的长度排序会更合适 。
这样不同字段的注解可以确保是统一顺序的,而且如果后续修改字段备注,也不会出现注解顺序前后变化的问题(同时也可以确保跟旧版的 generator 保持基本一致)
或者至少,给一个可以配置的配置项,或者能够 MybatisPlusConfig 配置类重写这个排序规则也可以,目前没办法修改这个配置
开放实体导包和字段注解处理(支持排序和动态添加).
d4ec84c
#6685
entityBuilder() .annotationAttributesFunction(annotationAttributes -> annotationAttributes.stream() .sorted(Comparator.comparingInt((AnnotationAttributes c) -> c.getDisplayName().charAt(1))).collect(Collectors.toList()))
No branches or pull requests
确认
当前程序版本
mybatis-plus-generator 3.5.10.1
问题描述
本 issue 与 #6682 一致
从以前的版本升级上来后,运行这个 generator 生成的 entity 注解的先后顺序不统一,会导致git历史出现很多修改。
如图,左侧为 3.5.9 版本生成的 entity(先 @Schema,后 @TableField),右侧为 3.5.10.1 版本生成的(@Schema,@TableField 前后顺序不一致)。
个人认为,此处排序应该
@Schema
@TableField
按照 s < t 排序)@Schema
@TableField
按照 "@Schema
".length (6) < "@TableField
".length (10) 排序)从结果来看,似乎当前是按照整行代码的长度进行排序,就导致了
@Schema
与@TableField
两者哪一行短哪行就在前面。详细堆栈日志
The text was updated successfully, but these errors were encountered: