use of com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerStatementParser in project druid by alibaba.
the class SQLServerSelectTest17 method test_simple.
public void test_simple() throws Exception {
String sql = "SELECT CIM_ASSET_TYPE.ID" + "\nFROM CIM_ASSET_TYPE" + "\nWHERE CIM_ASSET_TYPE.DEL_STATUS = '0'" + "\nAND NOT (" + "\nCIM_ASSET_TYPE.MODEL_TABLE IS NULL" + "\nOR CIM_ASSET_TYPE.MODEL_TABLE = ''" + //
")";
String expect = "SELECT CIM_ASSET_TYPE.ID" + "\nFROM CIM_ASSET_TYPE" + "\nWHERE CIM_ASSET_TYPE.DEL_STATUS = '0'" + "\n\tAND NOT (CIM_ASSET_TYPE.MODEL_TABLE IS NULL" + "\n\tOR CIM_ASSET_TYPE.MODEL_TABLE = '')";
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
String text = TestUtils.outputSqlServer(stmt);
Assert.assertEquals(expect, text);
// System.out.println(text);
}
use of com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerStatementParser in project druid by alibaba.
the class SQLServerSelectTest19 method test_simple.
public void test_simple() throws Exception {
String sql = "SELECT p.BusinessEntityID, FirstName, LastName, PhoneNumber AS Phone" + "\nFROM Person.Person AS p" + "\nJOIN Person.PersonPhone AS pph ON p.BusinessEntityID = pph.BusinessEntityID" + "\nWHERE LastName LIKE 'G%'" + "\nORDER BY LastName, FirstName " + //
"\nFOR XML AUTO, TYPE, XMLSCHEMA, ELEMENTS XSINIL;";
String expect = "SELECT p.BusinessEntityID, FirstName, LastName, PhoneNumber AS Phone" + "\nFROM Person.Person p" + "\n\tJOIN Person.PersonPhone pph ON p.BusinessEntityID = pph.BusinessEntityID" + "\nWHERE LastName LIKE 'G%'" + "\nORDER BY LastName, FirstName" + "\nFOR XML , TYPE, XMLSCHEMA, ELEMENTS XSINIL;";
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
String text = TestUtils.outputSqlServer(stmt);
Assert.assertEquals(expect, text);
// System.out.println(text);
}
use of com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerStatementParser in project druid by alibaba.
the class SQLServerSelectTest3 method test_isEmpty.
public void test_isEmpty() throws Exception {
String sql = "SELECT name + ‘-’ + master.sys.fn_varbintohexstr(password_hash) from master.sys.sql_logins";
String expect = //
"SELECT name + ‘ - ’ + master.sys.fn_varbintohexstr(password_hash)\n" + "FROM master.sys.sql_logins";
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
String text = TestUtils.outputSqlServer(stmt);
Assert.assertEquals(expect, text);
// System.out.println(text);
}
use of com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerStatementParser in project druid by alibaba.
the class SQLServerSelectTest5 method test_isEmpty.
public void test_isEmpty() throws Exception {
String sql = "SELECT name, password_hash FROM [master].[sys].sql_logins";
String expect = //
"SELECT name, password_hash\n" + "FROM [master].[sys].sql_logins";
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
String text = TestUtils.outputSqlServer(stmt);
Assert.assertEquals(expect, text);
// System.out.println(text);
}
use of com.alibaba.druid.sql.dialect.sqlserver.parser.SQLServerStatementParser in project druid by alibaba.
the class SQLServerRowNumberTest method test_isEmpty.
public void test_isEmpty() throws Exception {
String sql = //
"SELECT c.FirstName, c.LastName" + //
" ,ROW_NUMBER() OVER(ORDER BY SalesYTD DESC) AS 'Row Number'" + //
" ,s.SalesYTD, a.PostalCode " + //
"FROM Sales.SalesPerson s " + //
" INNER JOIN Person.Contact c " + //
" ON s.SalesPersonID = c.ContactID" + //
" INNER JOIN Person.Address a " + //
" ON a.AddressID = c.ContactID " + //
"WHERE TerritoryID IS NOT NULL " + " AND SalesYTD <> 0;";
String expect = "SELECT c.FirstName, c.LastName, ROW_NUMBER() OVER (ORDER BY SalesYTD DESC) AS \"Row Number\", s.SalesYTD\n" + "\t, a.PostalCode\n" + "FROM Sales.SalesPerson s\n" + "\tINNER JOIN Person.Contact c ON s.SalesPersonID = c.ContactID\n" + "\tINNER JOIN Person.Address a ON a.AddressID = c.ContactID\n" + "WHERE TerritoryID IS NOT NULL\n" + "\tAND SalesYTD <> 0;";
SQLServerStatementParser parser = new SQLServerStatementParser(sql);
SQLStatement stmt = parser.parseStatementList().get(0);
String text = TestUtils.outputSqlServer(stmt);
Assert.assertEquals(expect, text);
// System.out.println(text);
}
Aggregations