lib/dialects/postgres/query/compiler.js
// Compiles a `listTables` query
Compiles a `listTables` query
Compiles a ` listTables ` query
listTables() {
    let schema = this.single.schema;
    if (schema) {
      schema = this.client.customWrapIdentifier(schema, identity);
    }
    let sql = `select table_name, table_schema,
                 (select obj_description(oid) FROM pg_class
                  where relkind = 'r' and relname = table_name) as table_comment
               from information_schema.tables where `;
    const bindings = [];
    if (schema) {
      sql += 'table_schema = ? and ';
      bindings.push(schema);
    } else {
      sql += `table_schema = 'public' and `;
    }
    sql += `table_catalog = ? and table_type = 'BASE TABLE'`;
    bindings.push(this.client.database());
    return {
      sql: sql,
      bindings: bindings,
      output(resp) {
        const out = resp.rows.reduce(function (tables, val) {
          tables[val.table_name] = {
            schema: val.table_schema,
            comment: val.table_comment,
          };
          return tables;
        }, {});
        return out;
      },
    };
  }
listTables ( ) { let schema = this . single . schema ; if ( schema ) { schema = this . client . customWrapIdentifier ( schema , identity ) ; } let sql = ` ` ; const bindings = [ ] ; if ( schema ) { sql += 'table_schema = ? and ' ; bindings . push ( schema ) ; } else { sql += ` ` ; } sql += ` ` ; bindings . push ( this . client . database ( ) ) ; return { sql : sql , bindings : bindings , output ( resp ) { const out = resp . rows . reduce ( function ( tables , val ) { tables [ val . table_name ] = { schema : val . table_schema , comment : val . table_comment , } ; return tables ; } , { } ) ; return out ; } , } ; }
Compiles a `listTables` query
Compiles a ` listTables ` query
//return resp.rows.map((table) => { //  return table.table_name; //});