visitReturning method
void
visitReturning(
- Returning e,
- void arg
)
override
Implementation
@override
void visitReturning(Returning e, void arg) {
// RETURNING was added in sqlite version 3.35.0
if (context.engineOptions.version < SqliteVersion.v3_35) {
context.reportError(AnalysisError(
type: AnalysisErrorType.notSupportedInDesiredVersion,
message: 'RETURNING requires sqlite version 3.35 or later',
relevantNode: e,
));
return;
}
// https://www.sqlite.org/lang_returning.html#limitations_and_caveats
// Returning is not allowed in triggers
if (_isInTopLevelTriggerStatement) {
context.reportError(AnalysisError(
type: AnalysisErrorType.illegalUseOfReturning,
message: 'RETURNING is not allowed in triggers',
relevantNode: e,
));
}
// Returning is not allowed against virtual tables
final parent = e.parent;
if (parent is HasPrimarySource) {
final source = parent.table;
if (source is TableReference) {
final referenced = source.resultSet?.unalias();
if (referenced is Table && referenced.isVirtual) {
context.reportError(AnalysisError(
type: AnalysisErrorType.illegalUseOfReturning,
message: 'RETURNING is not allowed against virtual tables',
relevantNode: e,
));
}
}
}
for (final column in e.columns) {
// Table wildcards are not currently allowed, see
// https://www.sqlite.org/src/info/132994c8b1063bfb
if (column is StarResultColumn && column.tableName != null) {
context.reportError(AnalysisError(
type: AnalysisErrorType.synctactic,
message: 'Columns in RETURNING may not use the TABLE.* syntax',
relevantNode: column,
));
} else if (column is ExpressionResultColumn) {
// While we're at it, window expressions aren't allowed either
if (column.expression is WindowFunctionInvocation) {
context.reportError(
AnalysisError(
type: AnalysisErrorType.illegalUseOfReturning,
message: 'Aggregate expressions are not allowed in RETURNING',
relevantNode: column.expression,
),
);
}
}
}
visitChildren(e, arg);
}