-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* 针对mysql loadbalance格式的url,加上connectTimeout等属性的识别支持 #5396 针对mysql loadbalance格式的url,加上connectTimeout等属性的识别支持 #5396 if (jdbcUrl.startsWith("jdbc:mysql://") || jdbcUrl.startsWith("jdbc:mysql:loadbalance://")) { 配套单侧验证ok,mvn validate验证ok,mvn clean install 无新增错误 * 解决PG时使用KeepSourceLocation不生效的问题 #5287 传入参数加上 features ,mvn validate 通过,单测验证ok
- Loading branch information
Showing
4 changed files
with
74 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
core/src/test/java/com/alibaba/druid/bvt/sql/postgresql/issues/Issue5287.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.alibaba.druid.bvt.sql.postgresql.issues; | ||
|
||
import java.util.Map; | ||
|
||
import com.alibaba.druid.DbType; | ||
import com.alibaba.druid.sql.SQLUtils; | ||
import com.alibaba.druid.sql.ast.SQLExpr; | ||
import com.alibaba.druid.sql.ast.SQLOrderBy; | ||
import com.alibaba.druid.sql.ast.SQLStatement; | ||
import com.alibaba.druid.sql.ast.expr.SQLIdentifierExpr; | ||
import com.alibaba.druid.sql.dialect.postgresql.ast.stmt.PGSelectStatement; | ||
import com.alibaba.druid.sql.parser.SQLParserFeature; | ||
import com.alibaba.druid.sql.parser.SQLParserUtils; | ||
import com.alibaba.druid.sql.parser.SQLStatementParser; | ||
import com.alibaba.druid.sql.visitor.SchemaStatVisitor; | ||
import com.alibaba.druid.stat.TableStat; | ||
|
||
import org.junit.Test; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* 验证 Postgresql 没有解析行号的问题 #5287 | ||
* | ||
* @author lizongbo | ||
* @see <a href="https://github.com/alibaba/druid/issues/5287">增强 #5287</a> | ||
*/ | ||
public class Issue5287 { | ||
|
||
@Test | ||
public void test_get_source_location() throws Exception { | ||
for (DbType dbType : new DbType[]{DbType.postgresql}) { | ||
String sql = | ||
"select * from t1 \n" | ||
+ " where a=1 \n" | ||
+ " and b =2 \n" | ||
+ " order by c desc;"; | ||
SQLStatementParser parser = SQLParserUtils.createSQLStatementParser(sql, dbType); | ||
PGSelectStatement statement = (PGSelectStatement) parser.parseStatement(); | ||
SQLOrderBy orderBy = statement.getSelect().getQueryBlock().getOrderBy(); | ||
SQLExpr cExpr = orderBy.getItems().get(0).getExpr(); | ||
SQLIdentifierExpr si = (SQLIdentifierExpr) cExpr; | ||
int sourceLine1 = si.getSourceLine(); | ||
System.out.println(" statement.getSourceLine()===" + orderBy.getSourceLine() + "||" + sourceLine1); | ||
assertEquals(0, sourceLine1); | ||
parser = SQLParserUtils.createSQLStatementParser(sql, dbType, SQLParserFeature.KeepSourceLocation); | ||
statement = (PGSelectStatement) parser.parseStatement(); | ||
orderBy = statement.getSelect().getQueryBlock().getOrderBy(); | ||
cExpr = orderBy.getItems().get(0).getExpr(); | ||
si = (SQLIdentifierExpr) cExpr; | ||
int sourceLine2 = si.getSourceLine(); | ||
System.out.println(" statement.getSourceLine()===" + orderBy.getSourceLine() + "||" + sourceLine2); | ||
assertEquals(4, sourceLine2); | ||
|
||
} | ||
} | ||
} |