drift/sqlparser/test/parser/delete_test.dart

35 lines
828 B
Dart
Raw Normal View History

2019-06-29 13:47:40 -07:00
import 'package:sqlparser/src/reader/tokenizer/token.dart';
import 'package:test/test.dart';
import 'package:sqlparser/sqlparser.dart';
import 'utils.dart';
void main() {
test('parses delete statements', () {
2019-06-30 06:25:39 -07:00
testStatement(
'DELETE FROM tbl WHERE id = 5',
2019-06-29 13:47:40 -07:00
DeleteStatement(
from: TableReference('tbl', null),
2019-06-29 13:47:40 -07:00
where: BinaryExpression(
Reference(columnName: 'id'),
token(TokenType.equal),
NumericLiteral(
5,
token(TokenType.numberLiteral),
),
),
),
);
});
2021-03-13 11:41:14 -08:00
test('parses delete statements with RETURNING', () {
testStatement(
'DELETE FROM tbl RETURNING *;',
DeleteStatement(
from: TableReference('tbl', null),
returning: Returning([StarResultColumn()]),
),
);
});
2019-06-29 13:47:40 -07:00
}