use of com.alibaba.druid.sql.ast.statement.SQLGrantStatement in project druid by alibaba.
the class MySqlGrantTest_ads method test_doc_3.
public void test_doc_3() throws Exception {
String sql = "GRANT describe, select (col1, col2) ON db_name.table_name TO 'ALIYUN$account_name';";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLGrantStatement stmt = (SQLGrantStatement) statementList.get(0);
assertEquals(1, statementList.size());
assertEquals(//
"GRANT DESCRIBE, SELECT(col1, col2) ON db_name.table_name TO 'ALIYUN$account_name';", stmt.toString());
}
use of com.alibaba.druid.sql.ast.statement.SQLGrantStatement in project druid by alibaba.
the class MySqlGrantTest_ads method test_doc_0.
public void test_doc_0() throws Exception {
String sql = "GRANT describe, select ON db_name.table_group_name TO 'ALIYUN$account_name'@'%';";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLGrantStatement stmt = (SQLGrantStatement) statementList.get(0);
assertEquals(1, statementList.size());
assertEquals(//
"GRANT DESCRIBE, SELECT ON db_name.table_group_name TO 'ALIYUN$account_name'@'%';", stmt.toString());
}
use of com.alibaba.druid.sql.ast.statement.SQLGrantStatement in project druid by alibaba.
the class MySqlGrantTest_ads method test_doc_1.
public void test_doc_1() throws Exception {
String sql = "GRANT all ON db_name.table_group_name TO 'ALIYUN$account_name'@'%';";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLGrantStatement stmt = (SQLGrantStatement) statementList.get(0);
assertEquals(1, statementList.size());
assertEquals(//
"GRANT ALL ON db_name.table_group_name TO 'ALIYUN$account_name'@'%';", stmt.toString());
}
use of com.alibaba.druid.sql.ast.statement.SQLGrantStatement in project druid by alibaba.
the class MySqlGrantTest_ads method test_doc_2.
public void test_doc_2() throws Exception {
String sql = "GRANT describe, select (col1, col2) ON db_name.* TO 'ALIYUN$account_name';";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLGrantStatement stmt = (SQLGrantStatement) statementList.get(0);
assertEquals(1, statementList.size());
assertEquals(//
"GRANT DESCRIBE, SELECT(col1, col2) ON db_name.* TO 'ALIYUN$account_name';", stmt.toString());
}
use of com.alibaba.druid.sql.ast.statement.SQLGrantStatement in project druid by alibaba.
the class MySqlGrantTest_35 method test_6.
public void test_6() throws Exception {
String sql = "grant all on *.* to 'xx'@'localhost' with grant option";
MySqlStatementParser parser = new MySqlStatementParser(sql);
List<SQLStatement> statementList = parser.parseStatementList();
SQLGrantStatement stmt = (SQLGrantStatement) statementList.get(0);
assertEquals(1, statementList.size());
assertTrue(stmt.getWithGrantOption());
MySqlSchemaStatVisitor visitor = new MySqlSchemaStatVisitor();
stmt.accept(visitor);
assertEquals(//
"GRANT ALL ON *.* TO 'xx'@'localhost' WITH GRANT OPTION", stmt.toString());
assertEquals(//
"grant ALL on *.* to 'xx'@'localhost' with grant option", stmt.toLowerCaseString());
assertEquals(1, visitor.getTables().size());
assertEquals(0, visitor.getColumns().size());
assertEquals(0, visitor.getConditions().size());
}
Aggregations