Search in sources :

Example 1 with ProcType

use of org.jooq.meta.mysql.mysql.enums.ProcType in project jOOQ by jOOQ.

the class MySQLDatabase method getRoutines0.

@Override
protected List<RoutineDefinition> getRoutines0() throws SQLException {
    List<RoutineDefinition> result = new ArrayList<>();
    Result<Record6<String, String, String, byte[], byte[], ProcType>> records = is8() ? create().select(ROUTINES.ROUTINE_SCHEMA, ROUTINES.ROUTINE_NAME, ROUTINES.ROUTINE_COMMENT, inline(new byte[0]).as(PROC.PARAM_LIST), inline(new byte[0]).as(PROC.RETURNS), ROUTINES.ROUTINE_TYPE.coerce(PROC.TYPE).as(ROUTINES.ROUTINE_TYPE)).from(ROUTINES).where(ROUTINES.ROUTINE_SCHEMA.in(getInputSchemata())).orderBy(1, 2, 6).fetch() : create().select(PROC.DB.as(ROUTINES.ROUTINE_SCHEMA), PROC.NAME.as(ROUTINES.ROUTINE_NAME), PROC.COMMENT.as(ROUTINES.ROUTINE_COMMENT), PROC.PARAM_LIST, PROC.RETURNS, PROC.TYPE.as(ROUTINES.ROUTINE_TYPE)).from(PROC).where(PROC.DB.in(getInputSchemata())).orderBy(1, 2, 6).fetch();
    Map<Record, Result<Record6<String, String, String, byte[], byte[], ProcType>>> groups = records.intoGroups(new Field[] { ROUTINES.ROUTINE_SCHEMA, ROUTINES.ROUTINE_NAME });
    // [#1908] This indirection is necessary as MySQL allows for overloading
    // procedures and functions with the same signature.
    groups.forEach((k, overloads) -> {
        overloads.forEach(record -> {
            SchemaDefinition schema = getSchema(record.get(ROUTINES.ROUTINE_SCHEMA));
            String name = record.get(ROUTINES.ROUTINE_NAME);
            String comment = record.get(ROUTINES.ROUTINE_COMMENT);
            String params = is8() ? "" : new String(record.get(PROC.PARAM_LIST));
            String returns = is8() ? "" : new String(record.get(PROC.RETURNS));
            ProcType type = record.get(ROUTINES.ROUTINE_TYPE.coerce(PROC.TYPE).as(ROUTINES.ROUTINE_TYPE));
            if (overloads.size() > 1)
                result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, "_" + type.name()));
            else
                result.add(new MySQLRoutineDefinition(schema, name, comment, params, returns, type, null));
        });
    });
    return result;
}
Also used : RoutineDefinition(org.jooq.meta.RoutineDefinition) SchemaDefinition(org.jooq.meta.SchemaDefinition) ArrayList(java.util.ArrayList) ProcType(org.jooq.meta.mysql.mysql.enums.ProcType) Record6(org.jooq.Record6) Record(org.jooq.Record) Result(org.jooq.Result)

Aggregations

ArrayList (java.util.ArrayList)1 Record (org.jooq.Record)1 Record6 (org.jooq.Record6)1 Result (org.jooq.Result)1 RoutineDefinition (org.jooq.meta.RoutineDefinition)1 SchemaDefinition (org.jooq.meta.SchemaDefinition)1 ProcType (org.jooq.meta.mysql.mysql.enums.ProcType)1