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

[Enhancement] Nullsafety #153

Closed
wants to merge 33 commits into from
Closed

Conversation

j4qfrost
Copy link

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.

@isoos
Copy link
Collaborator

isoos commented Feb 26, 2021

Thank you, I'll find some time to review this soon.

Copy link
Collaborator

@isoos isoos left a 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 Show resolved Hide resolved
@@ -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,
Copy link
Collaborator

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.

Map<String, dynamic> substitutionValues,
bool allowReuse,
int timeoutInSeconds,
Map<String, dynamic> substitutionValues = const {},
Copy link
Collaborator

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 {},
Copy link
Collaborator

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.

if (returningException != null) {
query.completeError(returningException);
if (message.state == ReadyForQueryMessage.StateTransactionError) {
Copy link
Collaborator

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?

Copy link
Author

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.

Copy link
Author

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.

@j4qfrost
Copy link
Author

@isoos

First check looks really good, I have only a few small worries and requests.
Please also write a CHANGELOG entry for this change.

Should I bump the version up too? Seems like a major release.

Copy link
Collaborator

@isoos isoos left a 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,
Copy link
Collaborator

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,
Copy link
Collaborator

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,
Copy link
Collaborator

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

@j4qfrost
Copy link
Author

j4qfrost commented Feb 28, 2021 via email

@isoos
Copy link
Collaborator

isoos commented Feb 28, 2021

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.

@j4qfrost
Copy link
Author

j4qfrost commented Feb 28, 2021 via email

@isoos
Copy link
Collaborator

isoos commented Feb 28, 2021

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.

@hpoul
Copy link

hpoul commented Feb 28, 2021

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)

@j4qfrost
Copy link
Author

j4qfrost commented Feb 28, 2021 via email

@isoos
Copy link
Collaborator

isoos commented Mar 13, 2021

This has been adopted in my soft-fork repository and published as 2.3.0-null-safety.0.

@isoos isoos closed this Mar 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants