示例#1
0
        public void TestTableColumnsSQL()
        {
            _context.Input = @"CREATE PROCEDURE sp{TABLE.NAME}_Insert(
{TABLE.COLUMNS NOPRIMARY}	@{COLUMN.NAME}	{COLUMN.TYPE},
{/TABLE.COLUMNS}{TABLE.COLUMNS PRIMARY}@{COLUMN.NAME} {COLUMN.TYPE} OUTPUT{/TABLE.COLUMNS}
)
AS
INSERT INTO {TABLE.NAME} ({TABLE.COLUMNS}{COLUMN.NAME}{IF NOT LAST},{/IF}
{/TABLE.COLUMNS}) 
VALUES({TABLE.COLUMNS}@{COLUMN.NAME}{IF NOT LAST},{/IF}
{/TABLE.COLUMNS})
{TABLE.COLUMNS PRIMARY}
SET @{COLUMN.NAME} = @{COLUMN.NAME}
{/TABLE.COLUMNS}
";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnNameExpression());
            columns.AddExpression(new ColumnTypeExpression());
            columns.AddExpression(new ColumnLengthExpression());
            columns.AddExpression(new ColumnIfExpression());
            _parser.AddExpression(columns);
            _parser.AddExpression(new TableNameExpression());
            _parser.Interpret(_context);
        }
示例#2
0
        public void TestTableColumnsClass()
        {
            _context.Input = @"public class {TABLE.NAME}{
	{TABLE.COLUMNS}
	private {MAP COLUMN.TYPE} _{COLUMN.NAME}; //{COLUMN.LENGHT} {TABLE.NULLABLE}
	{/TABLE.COLUMNS}
	
	public void {TABLE.NAME}(){
	}

	{TABLE.COLUMNS}
	//{TABLE.NAME}
	public {MAP COLUMN.TYPE} {COLUMN.NAME}
	{
	set{ _{COLUMN.NAME} = value; }	
	get{ return _{COLUMN.NAME}; }
	}
	{/TABLE.COLUMNS}
}
";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnNameExpression());
            columns.AddExpression(new ColumnTypeExpression());
            columns.AddExpression(new ColumnMapTypeExpression());
            //columns.AddExpression(new LiteralExpression("[A-Z. ]+",""));
            _parser.AddExpression(columns);
            _parser.AddExpression(new TableNameExpression());
            _parser.Interpret(_context);
        }
示例#3
0
        public void TestIfNullable()
        {
            _context.Input = @"{TABLE.COLUMNS}{IF COLUMN.NULLABLE}{COLUMN.NAME}=NULL{/IF}{IF NOT COLUMN.NULLABLE}FALSE{/IF} {/TABLE.COLUMNS}";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnNameExpression());
            columns.AddExpression(new ColumnIfNullableExpression());
            _parser.AddExpression(columns);
            _parser.Interpret(_context);
        }
示例#4
0
        public void TestIfType()
        {
            _context.Input = @"
{TABLE.COLUMNS}
{IF COLUMN.TYPE EQ 'int|numeric()'}int _{COLUMN.NAME}{/IF}
{IF COLUMN.TYPE NE 'int'}string _{COLUMN.NAME}{/IF}
{/TABLE.COLUMNS}";
            ColumnsExpression colsExpression = new ColumnsExpression();

            colsExpression.AddExpression(new ColumnIfTypeExpression());
            colsExpression.AddExpression(new ColumnNameExpression());
            _parser.AddExpression(colsExpression);
            _parser.Interpret(_context);
        }
示例#5
0
        public void TestColumnNameMatchesExpression()
        {
            _context.Input = @"{TABLE.COLUMNS}" +
                             @"{IF COLUMN.NAME =~ 'Id$'}{COLUMN.NAME} ES ID{/IF}" +
                             "\n" +
                             @"{IF COLUMN.NAME !~ 'Id$'}{COLUMN.NAME}{/IF}" +
                             "\n" +
                             "{/TABLE.COLUMNS}";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnNameExpression());
            columns.AddExpression(new ColumnNameMatchesExpression());
            _parser.AddExpression(columns);
            _parser.Interpret(_context);
        }
示例#6
0
        public void TestColumnsNoPrimary()
        {
            _context.Input = @"{TABLE.COLUMNS NOPRIMARY}{COLUMN.NAME}
{/TABLE.COLUMNS}";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnNameExpression());
            _parser.AddExpression(columns);
            _parser.Interpret(_context);
        }
示例#7
0
        public void TestColumnsIfLast()
        {
            _context.Input = @"{TABLE.COLUMNS}
{IF NOT LAST}NOT LAST{/IF}
{IF LAST}
LAST{/IF}
{/TABLE.COLUMNS}";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnIfExpression());
            _parser.AddExpression(columns);
            _parser.Interpret(_context);
        }
示例#8
0
        public void TestColumnNaming()
        {
            _context.Input = @"{TABLE.COLUMNS}" +
                             @"Normal: {COLUMN.NAME}" + "\n" +
//			                 @"Camel: {COLUMN.NAME CAMEL}" + "\n" +
//			                 @"Pascal: {COLUMN.NAME PASCAL}" + "\n" +
//			                 @"Upper: {COLUMN.NAME UPPER}" + "\n" +
//			                 @"Lower: {COLUMN.NAME LOWER}" + "\n" +
                             @"Underscore: {COLUMN.NAME UNDERSCORE}" + "\n" +
                             @"Human: {COLUMN.NAME HUMAN}" + "\n" +
                             @"{/TABLE.COLUMNS}";
            ColumnsExpression columns = new ColumnsExpression();

            columns.AddExpression(new ColumnNameExpression());
            _parser.AddExpression(columns);
            _parser.Interpret(_context);
//			Console.WriteLine(_context.Output);
        }