Esempio n. 1
0
            public static IAlterTableAction Build(PlSqlParser.AlterTableActionContext context)
            {
                if (context.addColumnAction() != null) {
                    var column = TableColumn.Form(context.addColumnAction().tableColumn(), new List<ColumnConstraint>());
                    return new AddColumnAction(column);
                }
                if (context.addConstraintAction() != null) {
                    var constraint = TableConstraint.Form(context.addConstraintAction().tableConstraint());
                    return new AddConstraintAction(constraint);
                }

                if (context.dropColumnAction() != null) {
                    var columnName = context.dropColumnAction().id().GetText();
                    return new DropColumnAction(columnName);
                }

                if (context.dropConstraintAction() != null) {
                    var constraintName = context.dropConstraintAction().id().GetText();
                    return new DropConstraintAction(constraintName);
                }

                if (context.dropPrimaryKeyAction() != null) {
                    return new DropPrimaryKeyAction();
                }

                if (context.dropDefaultAction() != null) {
                    var columnName = Name.Simple(context.dropDefaultAction().columnName());
                    return new DropDefaultAction(columnName);
                }

                if (context.setDefaultAction() != null) {
                    var columnName = Name.Simple(context.setDefaultAction().columnName());
                    var defaultValue = Expression.Build(context.setDefaultAction().expressionWrapper());
                    return new SetDefaultAction(columnName, defaultValue);
                }

                throw new ParseCanceledException("The ALTER TABLE action is not supported");
            }