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

bug: return导致后续参数不绑定,实际应该是continue #10

Open
LvliguoGithub opened this issue May 14, 2021 · 2 comments
Open

Comments

@LvliguoGithub
Copy link

@LvliguoGithub
Copy link
Author

continue也会有问题。此处应该先进入到R2dbcTypeHandler的逻辑中,否则会透传一些r2dbc驱动不支持的数据类型。
public void fillParams(Statement statement, BoundSql boundSql, Object parameter) {
List parameterMappings = boundSql.getParameterMappings();
if (parameterMappings != null) {
for (int i = 0; i < parameterMappings.size(); i++) {
ParameterMapping parameterMapping = parameterMappings.get(i);
if (parameterMapping.getMode() != ParameterMode.OUT) {
Object value;
String propertyName = parameterMapping.getProperty();
if (boundSql.hasAdditionalParameter(propertyName)) {
value = boundSql.getAdditionalParameter(propertyName);
} else if (parameter == null) {
value = null;
} else if (typeHandlerRegistry.hasTypeHandler(parameter.getClass())) {
value = parameter;
} else {
MetaObject metaObject = configuration.newMetaObject(parameter);
value = metaObject.getValue(propertyName);
}

                TypeHandler typeHandler = parameterMapping.getTypeHandler();
                try {
                    if (typeHandler instanceof R2DBCTypeHandler) {
                        ((R2DBCTypeHandler<Object>) typeHandler).setParameter(statement, i, value, parameterMapping.getJdbcType());
                    } else {
                        if (value == null) {
                            statement.bindNull(i, parameterMapping.getJavaType());
                        } else {
                            Class<?> parameterClass = value.getClass();
                            if (typeHandlerRegistry.hasTypeHandler(parameterClass)) {
                                typeHandlerRegistry.getTypeHandler(parameterClass).setParameter(statement, i, value, parameterMapping.getJdbcType());
                            } else {
                                statement.bind(i, value);
                            }
                        }
                    }

                } catch (TypeException e) {
                    throw new TypeException("Could not set parameters for mapping: " + parameterMapping + ". Cause: " + e, e);
                }
            }
        }
    }
}

@linux-china
Copy link
Owner

@naah69 这个你能查看一下否? 我看起来这段代码的逻辑好像有些问题: 直接return好像有些问题。

linux-china added a commit that referenced this issue May 18, 2021
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

No branches or pull requests

2 participants