analyze method

AnalysisContext analyze(
  1. String sql, {
  2. AnalyzeStatementOptions? stmtOptions,
})

Parses and analyzes the sql statement. The AnalysisContext returned contains all information about type hints, errors, and the parsed AST.

The analyzer needs to know all the available tables to resolve references and result columns, so all known tables should be registered using registerTable before calling this method. The stmtOptions can be used to pass additional options used to analyze this statement only.

Implementation

AnalysisContext analyze(String sql, {AnalyzeStatementOptions? stmtOptions}) {
  final result = parse(sql);
  final analyzed = analyzeParsed(result, stmtOptions: stmtOptions);

  // Add parsing errors that occurred at the beginning since they are the most
  // prominent problems.
  analyzed.errors.insertAll(0, result.errors.map(AnalysisError.fromParser));

  return analyzed;
}