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

key generator column set error column #2753

Closed
wanglichao1 opened this issue Jul 24, 2019 · 3 comments
Closed

key generator column set error column #2753

wanglichao1 opened this issue Jul 24, 2019 · 3 comments
Assignees

Comments

@wanglichao1
Copy link

I set "key-generator.column=id",but the generator value set on "type" column,I use version 4.0.0-RC1.
My config:
spring.shardingsphere.sharding.tables.user_integral_details.actual-data-nodes=ds.user_integral_details_$->{0..63} spring.shardingsphere.sharding.tables.user_integral_details.table-strategy.inline.sharding-column=user_id spring.shardingsphere.sharding.tables.user_integral_details.table-strategy.inline.algorithm-expression=user_integral_details_$->{user_id % 64} spring.shardingsphere.sharding.tables.user_integral_details.key-generator.column=id spring.shardingsphere.sharding.tables.user_integral_details.key-generator.type=SNOWFLAKE spring.shardingsphere.sharding.tables.user_integral_details.key-generator.props.worker.id=${SNOWFLAKE_WORKER_ID} spring.shardingsphere.sharding.tables.user_integral_details.key-generator.props.max.tolerate.time.difference.milliseconds=100

Debug info:
2019-07-24 11:01:22.674 INFO 19292 --- [nio-6001-exec-3] ShardingSphere-SQL : Logic SQL: insert into user_integral_details (create_date, modify_date, order_list, clazz_id, extend_id, integral, organization_id, project_id, reason, type, user_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) 2019-07-24 11:01:22.675 INFO 19292 --- [nio-6001-exec-3] ShardingSphere-SQL : SQLStatement: InsertStatement(super=DMLStatement(super=AbstractSQLStatement(type=DML, tables=Tables(tables=[Table(name=user_integral_details, alias=Optional.absent())]), routeConditions=Conditions(orCondition=OrCondition(andConditions=[AndCondition(conditions=[Condition(column=Column(name=user_id, tableName=user_integral_details), operator=EQUAL, compareOperator=null, positionValueMap={}, positionIndexMap={0=10})])])), encryptConditions=Conditions(orCondition=OrCondition(andConditions=[])), sqlTokens=[TableToken(tableName=user_integral_details, quoteCharacter=NONE, schemaNameLength=0), SQLToken(startIndex=34)], parametersIndex=11, logicSQL=insert into user_integral_details (create_date, modify_date, order_list, clazz_id, extend_id, integral, organization_id, project_id, reason, type, user_id) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)), deleteStatement=false, updateTableAlias={}, updateColumnValues={}, whereStartIndex=0, whereStopIndex=0, whereParameterStartIndex=0, whereParameterEndIndex=0), columnNames=[create_date, modify_date, order_list, clazz_id, extend_id, integral, organization_id, project_id, reason, type, user_id], values=[InsertValue(columnValues=[org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@73fa8879, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@29af73c1, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@56e8bb5, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@43086be, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@232e7f01, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@714d21de, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@8f2f61, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@a5cb8, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@500cedcf, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@48d775c1, org.apache.shardingsphere.core.parse.old.parser.expression.SQLPlaceholderExpression@315abf9d])]) 2019-07-24 11:01:22.675 INFO 19292 --- [nio-6001-exec-3] ShardingSphere-SQL : Actual SQL: ds ::: insert into user_integral_details_56 (create_date, modify_date, order_list, clazz_id, extend_id, integral, organization_id, project_id, reason, type, user_id, id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ::: [2019-07-24T11:01:22.627+0800, null, 1563937282627, 1331, null, 1.0, 184, 635, 协助管理, 360742367440936961, 22136, null]

@xiaolong7713
Copy link

xiaolong7713 commented Jul 24, 2019

I also encountered this problem, your SQL certainly contains a null value,The ID filled a NULL value column,you can alter SQL like this:

        <trim prefix="(" suffix=")" suffixOverrides=",">
			<if test="callId != null">call_id,</if>
			<if test="deviceIp != null">device_ip,</if>
			<if test="deviceMac != null">device_mac,</if>
			<if test="recordingAddress != null">recording_address,</if>
			<if test="duration != null">duration,</if>
			<if test="trunkNumber != null">trunk_number,</if>
			<if test="createTime != null">create_time,</if>
		</trim>
		<trim prefix="values (" suffix=")" suffixOverrides=",">
			<if test="callId != null">#{callId},</if>
			<if test="deviceIp != null">#{deviceIp},</if>
			<if test="deviceMac != null">#{deviceMac},</if>
			<if test="recordingAddress != null">#{recordingAddress},</if>
			<if test="duration != null">#{duration},</if>
			<if test="trunkNumber != null">#{trunkNumber},</if>
			<if test="createTime != null">#{createTime},</if>
		</trim>

@KomachiSion
Copy link
Member

For my test, the issue has been fixed in 4.0.0-RC2.

@KomachiSion KomachiSion removed this from the 4.0.0-RC3 milestone Jul 25, 2019
@KomachiSion
Copy link
Member

duplicate with #2252

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants