getTables method

  1. @override
Future<List<TableName>> getTables({
  1. bool doOrder = false,
})
override

Get the list of table names, if necessary doOrder.

Implementation

@override
Future<List<TableName>> getTables({bool doOrder = false}) async {
  List<TableName> tableNames = [];
  String orderBy = " ORDER BY table_name";
  if (!doOrder) {
    orderBy = "";
  }
  String sql =
      """SELECT table_schema, table_name FROM INFORMATION_SCHEMA.TABLES
      WHERE (TABLE_TYPE='BASE TABLE' or TABLE_TYPE='VIEW' or TABLE_TYPE='EXTERNAL')
      and table_name != 'geography_columns'
      and table_name != 'geometry_columns'
      and table_name != 'spatial_ref_sys'
      and table_name != 'raster_columns'
      and table_name != 'raster_overviews'
      $orderBy;""";
  var res = await select(sql);
  res?.forEach((QueryResultRow row) {
    var name = row.get('table_name');
    var schema = row.get('table_schema');
    if (schema != "public") {
      name = schema + "." + name;
    }
    tableNames.add(TableName(name));
  });
  return tableNames;
}