-
Notifications
You must be signed in to change notification settings - Fork 32
[Enhancement] Nullsafety #153
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
Conversation
Thank you, I'll find some time to review this soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First check looks really good, I have only a few small worries and requests.
Please also write a CHANGELOG entry for this change.
lib/src/connection.dart
Outdated
@@ -214,7 +215,7 @@ class PostgreSQLConnection extends Object | |||
/// default query timeout will be used. | |||
Future transaction( | |||
Future Function(PostgreSQLExecutionContext connection) queryBlock, { | |||
int commitTimeoutInSeconds, | |||
int commitTimeoutInSeconds = 30, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep these optional parameters as nullable and set a default value just before we use them.
lib/src/connection.dart
Outdated
Map<String, dynamic> substitutionValues, | ||
bool allowReuse, | ||
int timeoutInSeconds, | ||
Map<String, dynamic> substitutionValues = const {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep these optional parameters as nullable and set a default value just before we use them.
Future<int> execute(String fmtString, | ||
{Map<String, dynamic> substitutionValues, int timeoutInSeconds}) async { | ||
Future<int?> execute(String fmtString, | ||
{Map<String, dynamic> substitutionValues = const {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: I'd rather keep these optional parameters as nullable and set a default value just before we use them. Especially because it is important to be consistent about it, and there timeoutInSeconds
is nullable.
lib/src/connection_fsm.dart
Outdated
if (returningException != null) { | ||
query.completeError(returningException); | ||
if (message.state == ReadyForQueryMessage.StateTransactionError) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How sure are you that message.state == ReadyForQueryMessage.StateTransactionError
and returningException == null
is never true at the same time? Maybe this should handle it as the original code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was a bit of a mistake on my part, I nested message.state == ReadyForQueryMessage.StateTransactionError
within message is ReadyForQueryMessage
, because the first statement did a type check that made the second statement safe. Nesting it inside the returningException != null
if statement was overstepping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I may be misremembering my reasoning here.
Should I bump the version up too? Seems like a major release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I bump the version up too? Seems like a major release.
There is no functional or otherwise breaking change, so this could be 2.3.0
. The SDK constraint makes it clear for clients on 2.10 that they won't be able to use it. We can then do a 3.0.0 with the proposed change of the port
property and maybe other parts can have adjustments...
bool allowReuse, | ||
int timeoutInSeconds, | ||
Map<String, dynamic>? substitutionValues, | ||
bool allowReuse = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove all of these default values. It makes it much easier to develop a tool like package:postgres_pool
Map<String, dynamic>? substitutionValues, | ||
required bool allowReuse, | ||
int? timeoutInSeconds, | ||
bool resolveOids = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it could be explicitly required
too.
bool allowReuse, | ||
int timeoutInSeconds}) async { | ||
{Map<String, dynamic> substitutionValues = const {}, | ||
bool allowReuse = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here: please remove defaults
It does break for apps that use earlier versions of the flutter sdk though, right? Maybe a prerelease would work? Or a 2.3.0-nullsafety?
… On Feb 28, 2021, at 2:14 AM, István Soós ***@***.***> wrote:
@isoos commented on this pull request.
Should I bump the version up too? Seems like a major release.
There is no functional or otherwise breaking change, so this could be 2.3.0. The SDK constraint makes it clear for clients on 2.10 that they won't be able to use it. We can then do a 3.0.0 with the proposed change of the port property and maybe other parts can have adjustments...
In lib/src/connection.dart <#153 (comment)>:
> String fmtString, {
- Map<String, dynamic> substitutionValues,
- bool allowReuse,
- int timeoutInSeconds,
+ Map<String, dynamic>? substitutionValues,
+ bool allowReuse = true,
Please remove all of these default values. It makes it much easier to develop a tool like package:postgres_pool
In lib/src/connection.dart <#153 (comment)>:
> String fmtString, {
- Map<String, dynamic> substitutionValues,
- bool allowReuse,
- int timeoutInSeconds,
- bool resolveOids,
+ Map<String, dynamic>? substitutionValues,
+ required bool allowReuse,
+ int? timeoutInSeconds,
+ bool resolveOids = true,
it could be explicitly required too.
In lib/src/connection.dart <#153 (comment)>:
> String fmtString,
- {Map<String, dynamic> substitutionValues,
- bool allowReuse,
- int timeoutInSeconds}) async {
+ {Map<String, dynamic> substitutionValues = const {},
+ bool allowReuse = false,
same here: please remove defaults
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#153 (review)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA6S7P3CWRE56LVNHZLFFELTBIJQTANCNFSM4YGHD6JQ>.
|
I do not see how it would break them. As far as I know Flutter respects the Dart SDK constraints too.
I don't see it making much difference, it can work too. |
I’m still a bit new to nullsafety migration. My experiences have involved being yelled at pub get for conflicting dependencies. Just realized it’s the responsibility of the end user to upgrade the required sdk version to use the null safety features anyway. I need to check the naming standards for nullsafety. Now that I think about it -nullsafety might just be a sort of buzzword trick to get people to use the library. Does everything look ok outside of the versioning?
… On Feb 28, 2021, at 2:20 AM, István Soós ***@***.***> wrote:
It does break for apps that use earlier versions of the flutter sdk though, right?
I do not see how it would break them. As far as I know Flutter respects the Dart SDK constraints too.
Maybe a prerelease would work? Or a 2.3.0-nullsafety?
I don't see it making much difference, it can work too.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#153 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA6S7PYXCPYND65LWUXMQGTTBIKHNANCNFSM4YGHD6JQ>.
|
There are still pending default values in the public API that should be rather reverted, like |
Regarding version bump, this night be of interest: dart-lang/sdk#41398 (comment) (The -nullsafety prerelease tag was only recommended while pre-beta, nowadays there so no need for that any more) |
Yoops, I got it. Pushed.
… On Feb 28, 2021, at 2:34 AM, István Soós ***@***.***> wrote:
Does everything look ok outside of the versioning?
There are still pending default values in the public API that should be rather reverted, like int timeoutInSeconds = 30,. Otherwise I think it looks good.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#153 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AA6S7PYYWYUERQLNED5SV5TTBIL3HANCNFSM4YGHD6JQ>.
|
This has been adopted in my soft-fork repository and published as |
Other than the given nullsafety breaking change, I've changed the parameters for the the client to take the port number as an optional parameter.