query method
Runs every SQL statement in queries and returns its rows, as column
name to value maps, under the same key.
Implementation
@override
Future<Map<String, List<Map<String, dynamic>>>> query(
Map<String, String> queries,
) async {
final directory = Directory.systemTemp.createTempSync('supabase_typegen_');
try {
final file = File('${directory.path}/introspection.sql')
..writeAsStringSync(combineQueries(queries));
final ProcessResult result;
try {
result = await Process.run(executable, [
'db',
'query',
...target.arguments,
'--output',
'json',
'--file',
file.absolute.path,
]);
} on ProcessException catch (error) {
throw SupabaseCliException(
'The Supabase CLI could not be started (${error.message}). '
'Install it from https://supabase.com/docs/guides/cli/getting-started '
'and make sure `$executable` is on PATH.',
);
}
if (result.exitCode != 0) {
throw SupabaseCliException(
describeFailure(
_stripAnsi('${result.stderr}\n${result.stdout}'),
target: target,
),
);
}
return _rows(result.stdout as String, queries.keys);
} finally {
directory.deleteSync(recursive: true);
}
}