Skip to content
New issue

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

解决同一点的Tag实体类相互独立时,映射的Object类型可能发生错误的问题 #311

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

charle004
Copy link
Contributor

关键代码如图,执行 transformNode 的时候传入 resultType ,当 tagType 是 nodeType 的 子类时 才去将 nodeType 换成 tagType
image

Copy link
Collaborator

@CorvusYe CorvusYe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个实现可能会影响到已有功能的结果格式。
可以描述一下期望达到的效果,咱再想想怎么实现合适一些。

Comment on lines +89 to +98
: value.isDate() ? transformDate(value.asDate())
: value.isDateTime() ? transformDateTime(value.asDateTime())
: value.isVertex() ? transformNode(value.asNode(),resultType)
: value.isEdge() ? transformRelationship(value)
: value.isPath() ? value.asPath()
: value.isList() ? transformList(value.asList())
: value.isSet() ? transformSet(value.asSet())
: value.isMap() ? transformMap(value.asMap())
: value.isDuration() ? transformDuration(value.asDuration())
: null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我也觉得这个格式看起来会更符合一些,但是代码风格校验会通不过

MapperContext mapperContext = MapperProxy.ENV.getMapperContext();
Map<String, Class<?>> tagTypeMapping = mapperContext.getTagTypeMapping();
Class<?> nodeType = null;
Class<?> nodeType = resultType;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这边可能会导致 nodeType 始终都不为空,可能会影响到现有的 如果无映射类型会将节点转换成 map 的功能。虽然正常不推荐该用法

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果只是找到 tagType 的时候 增加一个判断 resultType和tagType 是否具备继承关系,具备继承关系才赋予 nodeType 为tagType,这样应该可以不影响 转Map

@@ -79,24 +79,26 @@ public class ResultSetUtil {
* @param <T> 目标结果类型
* @return
*/
public static <T> T getValue(ValueWrapper value) {
public static <T> T getValue(ValueWrapper value,Class<T> resultType) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

公开方法如果要拓展,可能做一层重载会合适一些

@CorvusYe CorvusYe merged commit 6d1f7a9 into nebula-contrib:master Aug 21, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants