Skip to content

Commit b20509a

Browse files
authored
Fix compatibility with Drift 2.19.0 (#2162)
* Add support for drift 2.19.0 * Update * fix test * Update CHANGELOG * Add ignores
1 parent dd933d4 commit b20509a

File tree

4 files changed

+32
-2
lines changed

4 files changed

+32
-2
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Fixes
1212

13+
- Fix sentry_drift compatibility with Drift 2.19.0 ([#2162](https://github.com/getsentry/sentry-dart/pull/2162))
1314
- App starts hanging for 30s ([#2140](https://github.com/getsentry/sentry-dart/pull/2140))
1415
- Time out for app start info retrieval has been reduced to 10s
1516
- If `autoAppStarts` is `false` and `setAppStartEnd` has not been called, the app start event processor will now return early instead of waiting for `getAppStartInfo` to finish

drift/lib/src/sentry_query_executor.dart

+13-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ import 'dart:async';
33
import 'package:drift/drift.dart';
44
import 'package:meta/meta.dart';
55
import 'package:sentry/sentry.dart';
6-
import 'version.dart';
6+
77
import 'sentry_span_helper.dart';
88
import 'sentry_transaction_executor.dart';
9+
import 'version.dart';
910

1011
/// Signature of a function that opens a database connection when instructed to.
1112
typedef DatabaseOpener = FutureOr<QueryExecutor> Function();
@@ -167,6 +168,17 @@ class SentryQueryExecutor extends QueryExecutor {
167168
);
168169
}
169170

171+
@override
172+
// ignore: override_on_non_overriding_member, public_member_api_docs
173+
QueryExecutor beginExclusive() {
174+
final dynamic uncheckedExecutor = _executor;
175+
try {
176+
return uncheckedExecutor.beginExclusive() as QueryExecutor;
177+
} on NoSuchMethodError catch (_) {
178+
throw Exception('This method is not supported in Drift versions <2.19.0');
179+
}
180+
}
181+
170182
@override
171183
Future<void> close() {
172184
return _spanHelper.asyncWrapInSpan(

drift/lib/src/sentry_transaction_executor.dart

+12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:drift/backends.dart';
22
import 'package:meta/meta.dart';
33
import 'package:sentry/sentry.dart';
4+
45
import 'sentry_span_helper.dart';
56

67
/// @nodoc
@@ -134,6 +135,17 @@ class SentryTransactionExecutor extends TransactionExecutor {
134135
);
135136
}
136137

138+
@override
139+
// ignore: override_on_non_overriding_member, public_member_api_docs
140+
QueryExecutor beginExclusive() {
141+
final dynamic uncheckedExecutor = _executor;
142+
try {
143+
return uncheckedExecutor.beginExclusive() as QueryExecutor;
144+
} on NoSuchMethodError catch (_) {
145+
throw Exception('This method is not supported in Drift versions <2.19.0');
146+
}
147+
}
148+
137149
@override
138150
Future<int> runUpdate(String statement, List<Object?> args) {
139151
return _spanHelper.asyncWrapInSpan(

drift/test/sentry_database_test.dart

+6-1
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,14 @@ void main() {
324324
});
325325
} catch (_) {}
326326

327+
final spans = fixture.tracer.children
328+
.where((child) => child.status == SpanStatus.aborted());
329+
expect(spans.length, 1);
330+
final abortedSpan = spans.first;
331+
327332
verifySpan(
328333
expectedTransactionStatement,
329-
fixture.getCreatedSpan(),
334+
abortedSpan,
330335
origin: SentryTraceOrigins.autoDbDriftTransactionExecutor,
331336
status: SpanStatus.aborted(),
332337
);

0 commit comments

Comments
 (0)