Issue 1:
Bug Report

For English only, other languages will not accept.

Before report a bug, make sure you have:

Searched open and closed GitHub issues.

Read documentation: ShardingSphere Doc.

Please pay attention on issues you submitted, because we maybe need more details.

If no response more than 7 days and we cannot reproduce it on current information, we will close it.

Please answer these questions before submitting your issue. Thanks!

Which version of ShardingSphere did you use?

3.1.0

Which project did you use? Sharding-JDBC or Sharding-Proxy?

Sharding-JDBC

Expected behavior

no sharding tables use default-data-source

Actual behavior

no sharding tables's select actions did not use default-data-source(ds2) but use ds0.

But update,insert and delete actions use ds2

Reason analyze (If you can)

Steps to reproduce the behavior, such as: SQL to execute, sharding rule configuration, when exception occur etc.

config:

sharding:
jdbc:
datasource:
names: ds0,ds1,ds2
ds0:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://10.82.27.177:3306/ds0
username: root
password: 123456
ds1:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://10.82.27.177:3306/ds1
username: root
password: 123456
ds2:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://10.82.27.177:3306/ds2
username: root
password: 123456
config:
sharding:
# 默认数据源，可以将不分库分表的数据表放在这里
default-data-source-name: ds2
default-database-strategy:
inline:
sharding-column: uId
algorithm-expression: ds$->{uId % 2}
tables:
order:
key-generator-column-name: orderId
actual-data-nodes: ds$->{0..1}.order$->{0..1}
table-strategy:
inline:
sharding-column: orderId
algorithm-expression: order$->{orderId%2}
order_item:
key-generator-column-name: orderItemId
actual-data-nodes: ds$->{0..1}.order_item$->{0..1}
table-strategy:
inline:
sharding-column: orderId
algorithm-expression: orderItemId$->{orderId%2}
props:
sql.show: true

test sql

try (
try (
Connection conn = dataSource.getConnection();
Statement statement = conn.createStatement();
) {
statement.execute("insert into user(name,age) value('2012-12-12 12:12:12',1212)");
statement.execute("select * from user");
}

log:

ShardingSphere-SQL : Rule Type: sharding
ShardingSphere-SQL : Logic SQL: insert into user(name,age) value('2012-12-12 12:12:12',1212)
ShardingSphere-SQL : SQLStatement: InsertStatement(super=DMLStatement(super=io.shardingsphere.core.parsing.parser.sql.dml.insert.InsertStatement@33215ffb), columns=[Column(name=name, tableName=user), Column(name=age, tableName=user)], generatedKeyConditions=[], insertValues=InsertValues(insertValues=[InsertValue(type=VALUES, expression=('2012-12-12 12:12:12',1212), parametersCount=0)]), columnsListLastPosition=25, generateKeyColumnIndex=-1, insertValuesListLastPosition=60)
ShardingSphere-SQL : Actual SQL: ds2 ::: insert into user(name,age) value('2012-12-12 12:12:12',1212)
ShardingSphere-SQL : Rule Type: sharding
ShardingSphere-SQL : Logic SQL: select * from user
ShardingSphere-SQL : SQLStatement: SelectStatement(super=DQLStatement(super=io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement@12548f9a), containStar=true, firstSelectItemStartPosition=7, selectListLastPosition=9, groupByLastPosition=0, items=[StarSelectItem(owner=Optional.absent())], groupByItems=[], orderByItems=[], limit=null, subQueryStatement=null, subQueryStatements=[], subQueryConditions=[])

ShardingSphere-SQL : Actual SQL: ds0 ::: select * from user

Example codes for reproduce this issue (such as a github link).

Issue 2:
sharding jdbc & proxy

version:3.1.0

when i use sql like

" select snapshot_no from pt_item_base_snapshot where snapshot_no ='20190304152137155168409726302111' "

sharding-sphere can't get the value of column snapshot_no correctly

, it's always be -1;

I debug the source code ,in the class PredicateExtractor ,the method buildExpression

only support number:

Optional<ParserRuleContext> bitExprNode = ExtractorUtils.findFirstChildNode(valueNode, RuleName.BIT_EXPR); expressionNode = ExtractorUtils.findFirstChildNode(valueNode, RuleName.NUMBER); if (expressionNode.isPresent() && (!bitExprNode.isPresent() || 1 == bitExprNode.get().getChildCount())) { commonExpressionSegment.setValue(NumberUtil.getExactlyNumber(expressionNode.get().getText(), 10)); }

if I change code like ' expressionNode = ExtractorUtils.findFirstChildNode(valueNode, RuleName.STRING);' , the sql going well !