COUNT( 1 ) Spaces ERROR
The mybatis plus generated statement has Spaces: IService.count()
Example: SELECT COUNT( 1 ) FROM table;
Execution error:
Caused by: java.lang.IllegalStateException: Can't find index: AggregationSelectItem(type=COUNT, innerExpression=( 1 ), alias=Optional.absent(), derivedAggregationSelectItems=[], index=-1), please add alias for aggregate selections at com.google.common.base.Preconditions.checkState(Preconditions.java:507) at io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement.setIndexForAggregationItem(SelectStatement.java:186) at io.shardingsphere.core.parsing.parser.sql.dql.select.SelectStatement.setIndexForItems(SelectStatement.java:179) at io.shardingsphere.core.merger.dql.DQLMergeEngine.merge(DQLMergeEngine.java:69) at ### io.shardingsphere.shardingjdbc.jdbc.core.statement.ShardingPreparedStatement.getResultSet(ShardingPreparedStatement.java:185) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:69) at com.sun.proxy.$Proxy108.getResultSet(Unknown Source) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.getFirstResultSet(DefaultResultSetHandler.java:237) at org.apache.ibatis.executor.resultset.DefaultResultSetHandler.handleResultSets(DefaultResultSetHandler.java:187) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:65) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63) at com.sun.proxy.$Proxy106.query(Unknown Source) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:324) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:109) at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:83) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ... 45 more
I think the SQL was executed, but could not be parsed when the result set was fetched for a merge.
sharding-jdcb version: 3.0.0, 3.0.0.M3, 3.1.0 mybatis-plus version: 3.0.7.1
@wjvonline the issue was resolved, thanks
fixed at #2038
this problem is still exist on dev and v4.0.0.RC1. I will test 4.0.0.RC1.
i tested in dev and 4.0.0.RC1, the result is ok!

I reviewed the code of SelectItemFiller.java (tags 4.0.0.RC1), it is still not merge the #2306 bug fixs(bc9a5010c12897fd60aaa6f3e8a389e7f7cdd4b4). And I still have the problem.
SQL: select count( 1 ) from alarm where 1=1
Cause: java.lang.IllegalStateException: Can't find index: AggregationSelectItem(type=COUNT, innerExpression=( 1 ), alias=Optional.absent(), derivedAggregationSelectItems=[], index=-1), please add alias for aggregate selections
My local maven dependency is
i tested in dev and 4.0.0.RC1, the result is ok!
I find the point ,my database is PostgreSQL, so it is still use the old lexerEngine engine. So this issue is still exist in LexerEngine. Can you fix it?
I have the same issue in 4.0.0.RC2, did you fix it? My database is PostgreSQL too.