Example #1
0
  public boolean visit(SQLColumnDefinition x) {
    MySqlSQLColumnDefinition mysqlColumn = null;

    if (x instanceof MySqlSQLColumnDefinition) {
      mysqlColumn = (MySqlSQLColumnDefinition) x;
    }

    x.getName().accept(this);
    print(' ');
    x.getDataType().accept(this);

    if (x.getDefaultExpr() != null) {
      print(" DEFAULT ");
      x.getDefaultExpr().accept(this);
    }

    if (mysqlColumn != null && mysqlColumn.isAutoIncrement()) {
      print(" AUTO_INCREMENT");
    }

    for (SQLColumnConstraint item : x.getConstaints()) {
      print(' ');
      item.accept(this);
    }

    return false;
  }
  @Override
  public boolean visit(SQLAlterTableAddColumn x) {
    SQLAlterTableStatement stmt = (SQLAlterTableStatement) x.getParent();
    String table = stmt.getName().toString();

    for (SQLColumnDefinition column : x.getColumns()) {
      String columnName = column.getName().toString();
      addColumn(table, columnName);
    }
    return false;
  }
  public boolean visit(SQLColumnDefinition x) {
    String tableName = null;
    {
      SQLObject parent = x.getParent();
      if (parent instanceof SQLCreateTableStatement) {
        tableName = ((SQLCreateTableStatement) parent).getName().toString();
      }
    }

    if (tableName == null) {
      return true;
    }

    String columnName = x.getName().toString();
    addColumn(tableName, columnName);

    return false;
  }