Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

NOT IN parse exception #806

Closed
tiuuff opened this issue May 7, 2018 · 1 comment
Closed

NOT IN parse exception #806

tiuuff opened this issue May 7, 2018 · 1 comment
Assignees

Comments

@tiuuff
Copy link

tiuuff commented May 7, 2018

Which version of Sharding-Jdbc do you using?(您使用的Sharding-Jdbc版本为?)

2.0.3

Expected behavior (您预期的结果是)

SQL

select
create_time createTime ,
enterprise_id enterpriseId,
interval_log_id intervalLogId ,
interval_type intervalType ,
p_member_integral_name pmemberIntegralName ,
member_integral_name memberIntegralName ,
remark remark ,
interval_remark intervalRemark ,
interval_inout intervalInout ,
interval_history intervalHistory,
interval_status intervalStatus,
frozen_status frozenStatus,
unfreeze_time unfreezeTime,
interval_effect intervalEffect,
open_store_id openStoreId ,
main_part_store_id mainPartStoreId ,
main_store_id mainStoreId
from
tab_gic_member_interval_log
where
member_id in ('ff80808158016b390158041bfc7001eb','ff80808157dcf78e0157e67dbd611b28') and interval_history !=0 and p_member_integral_code not in('1000','1001')
order by create_time desc

分片的查询结果正确的按照create_time进行排序

Actual behavior (实际运行的结果是)

并没有按照时间排序

sql解析日志如下:
2018-05-07 11:48:21,021 INFO main Sharding-JDBC-SQL: SQLStatement:
SelectStatement(super=DQLStatement(super=AbstractSQLStatement(type=DQL, tables=Tables(tables=[Table(name=tab_gic_member_interval_log, alias=Optional.of(log))]), conditions=Conditions(conditions={Column(name=member_id, tableName=tab_gic_member_interval_log)=Condition(column=Column(name=member_id, tableName=tab_gic_member_interval_log), operator=IN, positionValueMap={0=ff80808158016b390158041bfc7001eb, 1=ff80808157dcf78e0157e67dbd611b28}, positionIndexMap={})}),
sqlTokens=[TableToken(beginPosition=765, originalLiterals=tab_gic_member_interval_log)], parametersIndex=0)),
containStar=false, selectListLastPosition=752, groupByLastPosition=0,
items=[CommonSelectItem(expression=log.interval_effect, alias=Optional.of(intervalEffect)), CommonSelectItem(expression=log.interval_type, alias=Optional.of(intervalType)), CommonSelectItem(expression=log.interval_history, alias=Optional.of(intervalHistory)), CommonSelectItem(expression=log.create_time, alias=Optional.of(createTime)), CommonSelectItem(expression=log.unfreeze_time, alias=Optional.of(unfreezeTime)), CommonSelectItem(expression=log.member_integral_name, alias=Optional.of(memberIntegralName)), CommonSelectItem(expression=log.remark, alias=Optional.of(remark)), CommonSelectItem(expression=log.interval_log_id, alias=Optional.of(intervalLogId)), CommonSelectItem(expression=log.p_member_integral_name, alias=Optional.of(pmemberIntegralName)), CommonSelectItem(expression=log.interval_remark, alias=Optional.of(intervalRemark)), CommonSelectItem(expression=log.enterprise_id, alias=Optional.of(enterpriseId)), CommonSelectItem(expression=log.interval_inout, alias=Optional.of(intervalInout)), CommonSelectItem(expression=log.main_part_store_id, alias=Optional.of(mainPartStoreId)), CommonSelectItem(expression=log.open_store_id, alias=Optional.of(openStoreId)), CommonSelectItem(expression=log.main_store_id, alias=Optional.of(mainStoreId)), CommonSelectItem(expression=log.interval_status, alias=Optional.of(intervalStatus)), CommonSelectItem(expression=log.frozen_status, alias=Optional.of(frozenStatus))], groupByItems=[], orderByItems=[], limit=null, subQueryStatement=null)

如果sql语句改为以下格式:

select
create_time createTime ,
enterprise_id enterpriseId,
interval_log_id intervalLogId ,
interval_type intervalType ,
p_member_integral_name pmemberIntegralName ,
member_integral_name memberIntegralName ,
remark remark ,
interval_remark intervalRemark ,
interval_inout intervalInout ,
interval_history intervalHistory,
interval_status intervalStatus,
frozen_status frozenStatus,
unfreeze_time unfreezeTime,
interval_effect intervalEffect,
open_store_id openStoreId ,
main_part_store_id mainPartStoreId ,
main_store_id mainStoreId
from
tab_gic_member_interval_log
where
member_id in ('ff80808158016b390158041bfc7001eb','ff80808157dcf78e0157e67dbd611b28') and interval_history !=0 and p_member_integral_code !='1000' and p_member_integral_code!='1001'
则能获得正常结果,其解析日志如下:

2018-05-07 11:53:58,058 INFO main Sharding-JDBC-SQL: SQLStatement: SelectStatement(super=DQLStatement(super=AbstractSQLStatement(type=DQL, tables=Tables(tables=[Table(name=tab_gic_member_interval_log, alias=Optional.absent())]), conditions=Conditions(conditions={Column(name=member_id, tableName=tab_gic_member_interval_log)=Condition(column=Column(name=member_id, tableName=tab_gic_member_interval_log), operator=IN, positionValueMap={0=ff80808158016b390158041bfc7001eb, 1=ff80808157dcf78e0157e67dbd611b28}, positionIndexMap={})}), sqlTokens=[TableToken(beginPosition=697, originalLiterals=tab_gic_member_interval_log)], parametersIndex=0)), containStar=false, selectListLastPosition=684, groupByLastPosition=884, items=[CommonSelectItem(expression=unfreeze_time, alias=Optional.of(unfreezeTime)), CommonSelectItem(expression=interval_log_id, alias=Optional.of(intervalLogId)), CommonSelectItem(expression=interval_inout, alias=Optional.of(intervalInout)), CommonSelectItem(expression=p_member_integral_name, alias=Optional.of(pmemberIntegralName)), CommonSelectItem(expression=frozen_status, alias=Optional.of(frozenStatus)), CommonSelectItem(expression=member_integral_name, alias=Optional.of(memberIntegralName)), CommonSelectItem(expression=enterprise_id, alias=Optional.of(enterpriseId)), CommonSelectItem(expression=interval_type, alias=Optional.of(intervalType)), CommonSelectItem(expression=remark, alias=Optional.of(remark)), CommonSelectItem(expression=create_time, alias=Optional.of(createTime)), CommonSelectItem(expression=interval_remark, alias=Optional.of(intervalRemark)), CommonSelectItem(expression=open_store_id, alias=Optional.of(openStoreId)), CommonSelectItem(expression=interval_effect, alias=Optional.of(intervalEffect)), CommonSelectItem(expression=main_store_id, alias=Optional.of(mainStoreId)), CommonSelectItem(expression=main_part_store_id, alias=Optional.of(mainPartStoreId)), CommonSelectItem(expression=interval_history, alias=Optional.of(intervalHistory)), CommonSelectItem(expression=interval_status, alias=Optional.of(intervalStatus))], groupByItems=[OrderItem(owner=Optional.absent(), name=Optional.of(create_time), type=ASC, nullOrderType=ASC, index=-1, alias=Optional.of(createTime))], orderByItems=[OrderItem(owner=Optional.absent(), name=Optional.of(create_time), type=DESC, nullOrderType=ASC, index=-1, alias=Optional.of(createTime))], limit=null, subQueryStatement=null)

@terrymanu
Copy link
Member

fixed at 3.0.0.M1

@terrymanu terrymanu changed the title Order by 解析异常 NOT IN解析异常 May 10, 2018
terrymanu added a commit that referenced this issue May 10, 2018
@terrymanu terrymanu changed the title NOT IN解析异常 Support NOT IN Aug 8, 2018
@terrymanu terrymanu changed the title Support NOT IN Support NOT IN Aug 8, 2018
@terrymanu terrymanu changed the title Support NOT IN NOT IN parse exception Aug 8, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants