2021-09-10 02:43:21 -07:00
|
|
|
import 'package:sqlparser/sqlparser.dart';
|
2019-06-29 13:47:40 -07:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
|
|
|
import 'utils.dart';
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
test('parses delete statements', () {
|
2019-06-30 06:25:39 -07:00
|
|
|
testStatement(
|
2019-07-26 04:49:25 -07:00
|
|
|
'DELETE FROM tbl WHERE id = 5',
|
2019-06-29 13:47:40 -07:00
|
|
|
DeleteStatement(
|
2021-07-22 12:32:53 -07:00
|
|
|
from: TableReference('tbl'),
|
2019-06-29 13:47:40 -07:00
|
|
|
where: BinaryExpression(
|
|
|
|
Reference(columnName: 'id'),
|
|
|
|
token(TokenType.equal),
|
|
|
|
NumericLiteral(
|
|
|
|
5,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
2021-03-13 11:41:14 -08:00
|
|
|
|
|
|
|
test('parses delete statements with RETURNING', () {
|
|
|
|
testStatement(
|
|
|
|
'DELETE FROM tbl RETURNING *;',
|
|
|
|
DeleteStatement(
|
2021-07-22 12:32:53 -07:00
|
|
|
from: TableReference('tbl'),
|
2021-03-13 11:41:14 -08:00
|
|
|
returning: Returning([StarResultColumn()]),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
});
|
2019-06-29 13:47:40 -07:00
|
|
|
}
|