Skip to content

fix: handle PgDataType.voidType #142

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

Merged
merged 2 commits into from
Oct 1, 2023
Merged

Conversation

osaxma
Copy link
Contributor

@osaxma osaxma commented Oct 1, 2023

Partly fixes #125

  • For PgDataType.voidType, return null.
  • For any unimplemented type, return whatever was decoded as text
    • I believe it's better to return something than throw an exception

Context:

I was running this query and I received the following error:

--> data ReadyForQueryMessage(state = I)
<-- data Instance of 'QueryMessage'
      sending Qnselect pg_drop_replication_slot('a_test_slot') from pg_replication_slots where slot_name = 'a_test_slot';
--> data Instance of 'RowDescriptionMessage'
--> data Data Row Message: [[]]
Unhandled exception:
UnimplementedError: Text decoding for PgDataType.voidType

@codecov-commenter
Copy link

codecov-commenter commented Oct 1, 2023

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (e22e648) 87.28% compared to head (5805557) 87.21%.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #142      +/-   ##
==========================================
- Coverage   87.28%   87.21%   -0.07%     
==========================================
  Files          29       29              
  Lines        2500     2502       +2     
==========================================
  Hits         2182     2182              
- Misses        318      320       +2     
Files Coverage Δ
lib/src/text_codec.dart 92.24% <0.00%> (-1.62%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

// ignore: no_default_cases
default:
throw UnimplementedError('Text decoding for $_dataType');
return asText as T;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe?

if (asText is T) return asText;
throw UnimplementedError('Text decoding for $_dataType');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        if (asText is T) {
          return asText as T; // i had to do it like this; otherwise it gives an error 
        }
        throw UnimplementedError('Text decoding for $_dataType');

@isoos isoos merged commit 3ee9d90 into isoos:master Oct 1, 2023
@isoos
Copy link
Owner

isoos commented Oct 1, 2023

thanks!

@osaxma osaxma deleted the handle_void_type branch October 1, 2023 19:49
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.

Unimplemented Text Decoding Types in PostgresTextDecoder
3 participants