Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with Drift 2.19.0 #2162

Merged
merged 5 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Fixes

- Fix sentry_drift compatibility with Drift 2.19.0 ([#2162](https://github.com/getsentry/sentry-dart/pull/2162))
- App starts hanging for 30s ([#2140](https://github.com/getsentry/sentry-dart/pull/2140))
- Time out for app start info retrieval has been reduced to 10s
- 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
Expand Down
14 changes: 13 additions & 1 deletion drift/lib/src/sentry_query_executor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
import 'package:drift/drift.dart';
import 'package:meta/meta.dart';
import 'package:sentry/sentry.dart';
import 'version.dart';

import 'sentry_span_helper.dart';
import 'sentry_transaction_executor.dart';
import 'version.dart';

/// Signature of a function that opens a database connection when instructed to.
typedef DatabaseOpener = FutureOr<QueryExecutor> Function();
Expand Down Expand Up @@ -167,6 +168,17 @@
);
}

@override

Check warning on line 171 in drift/lib/src/sentry_query_executor.dart

View check run for this annotation

Codecov / codecov/patch

drift/lib/src/sentry_query_executor.dart#L171

Added line #L171 was not covered by tests
// ignore: override_on_non_overriding_member, public_member_api_docs
QueryExecutor beginExclusive() {
final dynamic uncheckedExecutor = _executor;

Check warning on line 174 in drift/lib/src/sentry_query_executor.dart

View check run for this annotation

Codecov / codecov/patch

drift/lib/src/sentry_query_executor.dart#L174

Added line #L174 was not covered by tests
try {
return uncheckedExecutor.beginExclusive() as QueryExecutor;
} on NoSuchMethodError catch (_) {
throw Exception('This method is not supported in Drift versions <2.19.0');

Check warning on line 178 in drift/lib/src/sentry_query_executor.dart

View check run for this annotation

Codecov / codecov/patch

drift/lib/src/sentry_query_executor.dart#L176-L178

Added lines #L176 - L178 were not covered by tests
}
}

@override
Future<void> close() {
return _spanHelper.asyncWrapInSpan(
Expand Down
12 changes: 12 additions & 0 deletions drift/lib/src/sentry_transaction_executor.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:drift/backends.dart';
import 'package:meta/meta.dart';
import 'package:sentry/sentry.dart';

import 'sentry_span_helper.dart';

/// @nodoc
Expand Down Expand Up @@ -134,6 +135,17 @@
);
}

@override

Check warning on line 138 in drift/lib/src/sentry_transaction_executor.dart

View check run for this annotation

Codecov / codecov/patch

drift/lib/src/sentry_transaction_executor.dart#L138

Added line #L138 was not covered by tests
// ignore: override_on_non_overriding_member, public_member_api_docs
QueryExecutor beginExclusive() {
final dynamic uncheckedExecutor = _executor;

Check warning on line 141 in drift/lib/src/sentry_transaction_executor.dart

View check run for this annotation

Codecov / codecov/patch

drift/lib/src/sentry_transaction_executor.dart#L141

Added line #L141 was not covered by tests
try {
return uncheckedExecutor.beginExclusive() as QueryExecutor;
} on NoSuchMethodError catch (_) {
throw Exception('This method is not supported in Drift versions <2.19.0');

Check warning on line 145 in drift/lib/src/sentry_transaction_executor.dart

View check run for this annotation

Codecov / codecov/patch

drift/lib/src/sentry_transaction_executor.dart#L143-L145

Added lines #L143 - L145 were not covered by tests
}
}

@override
Future<int> runUpdate(String statement, List<Object?> args) {
return _spanHelper.asyncWrapInSpan(
Expand Down
7 changes: 6 additions & 1 deletion drift/test/sentry_database_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,14 @@ void main() {
});
} catch (_) {}

final spans = fixture.tracer.children
.where((child) => child.status == SpanStatus.aborted());
expect(spans.length, 1);
final abortedSpan = spans.first;

verifySpan(
expectedTransactionStatement,
fixture.getCreatedSpan(),
abortedSpan,
origin: SentryTraceOrigins.autoDbDriftTransactionExecutor,
status: SpanStatus.aborted(),
);
Expand Down
Loading