/*
 * This file is generated by jOOQ.
 */
package ervu_secret.ervu_secret.db_beans.information_schema.tables;


import ervu_secret.ervu_secret.db_beans.information_schema.Domains;
import ervu_secret.ervu_secret.db_beans.information_schema.InformationSchema;
import ervu_secret.ervu_secret.db_beans.information_schema.tables.records.ConstraintTableUsageRecord;

import java.util.Collection;

import org.jooq.Condition;
import org.jooq.Field;
import org.jooq.Name;
import org.jooq.PlainSQL;
import org.jooq.QueryPart;
import org.jooq.SQL;
import org.jooq.Schema;
import org.jooq.Select;
import org.jooq.Stringly;
import org.jooq.Table;
import org.jooq.TableField;
import org.jooq.TableOptions;
import org.jooq.impl.DSL;
import org.jooq.impl.TableImpl;


/**
 * This class is generated by jOOQ.
 */
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class ConstraintTableUsage extends TableImpl<ConstraintTableUsageRecord> {

    private static final long serialVersionUID = 1L;

    /**
     * The reference instance of
     * <code>information_schema.constraint_table_usage</code>
     */
    public static final ConstraintTableUsage CONSTRAINT_TABLE_USAGE = new ConstraintTableUsage();

    /**
     * The class holding records for this type
     */
    @Override
    public Class<ConstraintTableUsageRecord> getRecordType() {
        return ConstraintTableUsageRecord.class;
    }

    /**
     * The column
     * <code>information_schema.constraint_table_usage.table_catalog</code>.
     */
    public final TableField<ConstraintTableUsageRecord, String> TABLE_CATALOG = createField(DSL.name("table_catalog"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.constraint_table_usage.table_schema</code>.
     */
    public final TableField<ConstraintTableUsageRecord, String> TABLE_SCHEMA = createField(DSL.name("table_schema"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.constraint_table_usage.table_name</code>.
     */
    public final TableField<ConstraintTableUsageRecord, String> TABLE_NAME = createField(DSL.name("table_name"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.constraint_table_usage.constraint_catalog</code>.
     */
    public final TableField<ConstraintTableUsageRecord, String> CONSTRAINT_CATALOG = createField(DSL.name("constraint_catalog"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.constraint_table_usage.constraint_schema</code>.
     */
    public final TableField<ConstraintTableUsageRecord, String> CONSTRAINT_SCHEMA = createField(DSL.name("constraint_schema"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    /**
     * The column
     * <code>information_schema.constraint_table_usage.constraint_name</code>.
     */
    public final TableField<ConstraintTableUsageRecord, String> CONSTRAINT_NAME = createField(DSL.name("constraint_name"), Domains.SQL_IDENTIFIER.getDataType(), this, "");

    private ConstraintTableUsage(Name alias, Table<ConstraintTableUsageRecord> aliased) {
        this(alias, aliased, (Field<?>[]) null, null);
    }

    private ConstraintTableUsage(Name alias, Table<ConstraintTableUsageRecord> aliased, Field<?>[] parameters, Condition where) {
        super(alias, null, aliased, parameters, DSL.comment(""), TableOptions.view("""
        create view "constraint_table_usage" as  SELECT (current_database())::information_schema.sql_identifier AS table_catalog,
          (nr.nspname)::information_schema.sql_identifier AS table_schema,
          (r.relname)::information_schema.sql_identifier AS table_name,
          (current_database())::information_schema.sql_identifier AS constraint_catalog,
          (nc.nspname)::information_schema.sql_identifier AS constraint_schema,
          (c.conname)::information_schema.sql_identifier AS constraint_name
         FROM pg_constraint c,
          pg_namespace nc,
          pg_class r,
          pg_namespace nr
        WHERE ((c.connamespace = nc.oid) AND (r.relnamespace = nr.oid) AND (((c.contype = 'f'::"char") AND (c.confrelid = r.oid)) OR ((c.contype = ANY (ARRAY['p'::"char", 'u'::"char"])) AND (c.conrelid = r.oid))) AND (r.relkind = ANY (ARRAY['r'::"char", 'p'::"char"])) AND pg_has_role(r.relowner, 'USAGE'::text));
        """), where);
    }

    /**
     * Create an aliased <code>information_schema.constraint_table_usage</code>
     * table reference
     */
    public ConstraintTableUsage(String alias) {
        this(DSL.name(alias), CONSTRAINT_TABLE_USAGE);
    }

    /**
     * Create an aliased <code>information_schema.constraint_table_usage</code>
     * table reference
     */
    public ConstraintTableUsage(Name alias) {
        this(alias, CONSTRAINT_TABLE_USAGE);
    }

    /**
     * Create a <code>information_schema.constraint_table_usage</code> table
     * reference
     */
    public ConstraintTableUsage() {
        this(DSL.name("constraint_table_usage"), null);
    }

    @Override
    public Schema getSchema() {
        return aliased() ? null : InformationSchema.INFORMATION_SCHEMA;
    }

    @Override
    public ConstraintTableUsage as(String alias) {
        return new ConstraintTableUsage(DSL.name(alias), this);
    }

    @Override
    public ConstraintTableUsage as(Name alias) {
        return new ConstraintTableUsage(alias, this);
    }

    @Override
    public ConstraintTableUsage as(Table<?> alias) {
        return new ConstraintTableUsage(alias.getQualifiedName(), this);
    }

    /**
     * Rename this table
     */
    @Override
    public ConstraintTableUsage rename(String name) {
        return new ConstraintTableUsage(DSL.name(name), null);
    }

    /**
     * Rename this table
     */
    @Override
    public ConstraintTableUsage rename(Name name) {
        return new ConstraintTableUsage(name, null);
    }

    /**
     * Rename this table
     */
    @Override
    public ConstraintTableUsage rename(Table<?> name) {
        return new ConstraintTableUsage(name.getQualifiedName(), null);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ConstraintTableUsage where(Condition condition) {
        return new ConstraintTableUsage(getQualifiedName(), aliased() ? this : null, null, condition);
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ConstraintTableUsage where(Collection<? extends Condition> conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ConstraintTableUsage where(Condition... conditions) {
        return where(DSL.and(conditions));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ConstraintTableUsage where(Field<Boolean> condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ConstraintTableUsage where(SQL condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ConstraintTableUsage where(@Stringly.SQL String condition) {
        return where(DSL.condition(condition));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ConstraintTableUsage where(@Stringly.SQL String condition, Object... binds) {
        return where(DSL.condition(condition, binds));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    @PlainSQL
    public ConstraintTableUsage where(@Stringly.SQL String condition, QueryPart... parts) {
        return where(DSL.condition(condition, parts));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ConstraintTableUsage whereExists(Select<?> select) {
        return where(DSL.exists(select));
    }

    /**
     * Create an inline derived table from this table
     */
    @Override
    public ConstraintTableUsage whereNotExists(Select<?> select) {
        return where(DSL.notExists(select));
    }
}
