Search in sources :

Example 1 with TypeDefExpr

use of net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr in project JSqlParser by JSQLParser.

the class DeclareStatementTest method testDeclareTypeList.

@Test
public void testDeclareTypeList() throws JSQLParserException {
    String statement = "DECLARE @group nvarchar (50), @sales money";
    Statement parsed = assertSqlCanBeParsedAndDeparsed(statement);
    DeclareStatement created = new DeclareStatement().addTypeDefExprList(asList(new TypeDefExpr(new UserVariable().withName("group"), new ColDataType().withDataType("nvarchar").addArgumentsStringList("50"), null), new TypeDefExpr(new UserVariable().withName("sales"), new ColDataType().withDataType("money"), null))).withDeclareType(DeclareType.TYPE);
    assertDeparse(created, statement);
    assertEqualsObjectTree(parsed, created);
}
Also used : TypeDefExpr(net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr) ColDataType(net.sf.jsqlparser.statement.create.table.ColDataType) UserVariable(net.sf.jsqlparser.expression.UserVariable) Test(org.junit.jupiter.api.Test)

Example 2 with TypeDefExpr

use of net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr in project JSqlParser by JSQLParser.

the class DeclareStatementTest method testDeclareTypeWithDefault.

@Test
public void testDeclareTypeWithDefault() throws JSQLParserException {
    String statement = "DECLARE @find varchar (30) = 'Man%'";
    Statement parsed = assertSqlCanBeParsedAndDeparsed(statement);
    DeclareStatement created = new DeclareStatement().addTypeDefExprList(new TypeDefExpr(new UserVariable().withName("find"), new ColDataType().withDataType("varchar").addArgumentsStringList("30"), new StringValue().withValue("Man%"))).withDeclareType(DeclareType.TYPE);
    assertDeparse(created, statement);
    assertEqualsObjectTree(parsed, created);
}
Also used : TypeDefExpr(net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr) ColDataType(net.sf.jsqlparser.statement.create.table.ColDataType) StringValue(net.sf.jsqlparser.expression.StringValue) UserVariable(net.sf.jsqlparser.expression.UserVariable) Test(org.junit.jupiter.api.Test)

Example 3 with TypeDefExpr

use of net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr in project JSqlParser by JSQLParser.

the class DeclareStatementTest method testDeclareType.

@Test
public void testDeclareType() throws JSQLParserException {
    String statement = "DECLARE @find nvarchar (30)";
    Statement parsed = assertSqlCanBeParsedAndDeparsed(statement);
    DeclareStatement created = new DeclareStatement().addTypeDefExprList(new TypeDefExpr(new UserVariable().withName("find"), new ColDataType().withDataType("nvarchar").addArgumentsStringList("30"), null)).withDeclareType(DeclareType.TYPE);
    assertDeparse(created, statement);
    assertEqualsObjectTree(parsed, created);
}
Also used : TypeDefExpr(net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr) ColDataType(net.sf.jsqlparser.statement.create.table.ColDataType) UserVariable(net.sf.jsqlparser.expression.UserVariable) Test(org.junit.jupiter.api.Test)

Aggregations

UserVariable (net.sf.jsqlparser.expression.UserVariable)3 TypeDefExpr (net.sf.jsqlparser.statement.DeclareStatement.TypeDefExpr)3 ColDataType (net.sf.jsqlparser.statement.create.table.ColDataType)3 Test (org.junit.jupiter.api.Test)3 StringValue (net.sf.jsqlparser.expression.StringValue)1