Search in sources :

Example 1 with MySqlObject

use of com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject in project druid by alibaba.

the class SQLUtils method toSQLString.

public static String toSQLString(SQLObject obj) {
    if (obj instanceof SQLStatement) {
        SQLStatement stmt = (SQLStatement) obj;
        return toSQLString(stmt, stmt.getDbType());
    }
    if (obj instanceof MySqlObject) {
        return toMySqlString(obj);
    }
    StringBuilder out = new StringBuilder();
    obj.accept(new SQLASTOutputVisitor(out));
    String sql = out.toString();
    return sql;
}
Also used : MySqlObject(com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject) SQLASTOutputVisitor(com.alibaba.druid.sql.visitor.SQLASTOutputVisitor)

Example 2 with MySqlObject

use of com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject in project druid by alibaba.

the class SQLObjectImpl method output.

public void output(Appendable buf) {
    DbType dbType = null;
    if (this instanceof OracleSQLObject) {
        dbType = DbType.oracle;
    } else if (this instanceof MySqlObject) {
        dbType = DbType.mysql;
    } else if (this instanceof PGSQLObject) {
        dbType = DbType.postgresql;
    } else if (this instanceof SQLDbTypedObject) {
        dbType = ((SQLDbTypedObject) this).getDbType();
    }
    accept(SQLUtils.createOutputVisitor(buf, dbType));
}
Also used : PGSQLObject(com.alibaba.druid.sql.dialect.postgresql.ast.PGSQLObject) OracleSQLObject(com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObject) MySqlObject(com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject) DbType(com.alibaba.druid.DbType)

Aggregations

MySqlObject (com.alibaba.druid.sql.dialect.mysql.ast.MySqlObject)2 DbType (com.alibaba.druid.DbType)1 OracleSQLObject (com.alibaba.druid.sql.dialect.oracle.ast.OracleSQLObject)1 PGSQLObject (com.alibaba.druid.sql.dialect.postgresql.ast.PGSQLObject)1 SQLASTOutputVisitor (com.alibaba.druid.sql.visitor.SQLASTOutputVisitor)1