createView method
Executes a CREATE VIEW
statement to create the view
.
Implementation
Future<void> createView(ViewInfo view) async {
final stmt = view.createViewStmt;
if (stmt != null) {
await _issueCustomQuery(stmt, const []);
} else if (view.query != null) {
final context = GenerationContext.fromDb(_db, supportsVariables: false);
final columnNames = view.$columns.map((e) => e.escapedName).join(', ');
context.generatingForView = view.entityName;
context.buffer.write(
'CREATE VIEW IF NOT EXISTS ${view.entityName} ($columnNames) AS ');
view.query!.writeInto(context);
await _issueCustomQuery(context.sql, const []);
}
}