Skip to content

Using a bytea and Realtime leads to a double-encoded result #1180

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

Open
gagik opened this issue Jun 1, 2025 · 0 comments
Open

Using a bytea and Realtime leads to a double-encoded result #1180

gagik opened this issue Jun 1, 2025 · 0 comments
Labels
bug Something isn't working realtime This issue or pull request is related to realtime

Comments

@gagik
Copy link

gagik commented Jun 1, 2025

Describe the bug
I store data in a bytea column and subscribe to it using Realtime. Simply storing data with

String _bytesToHex(Uint8List bytes) {
    final buffer = StringBuffer();
    for (final byte in bytes) {
      buffer.write(byte.toRadixString(16).padLeft(2, '0'));
    }
    return buffer.toString();
  }i

await _supabase.from('test').upsert({
 'data': '\\x${_bytesToHex(Uint8List([1, 2, 3])}', /
})

// This is fine
_hexToBytes(await _supabase.from('test').upsert({
 'data': '\\x${_bytesToHex(Uint8List([1, 2, 3])}', /
}).select());

leads to a consistent result in the Supabase dashboard as well as when trying to retrieving it using a SELECT.

However, when I have a subscription to this table, i.e.

 _backendSubscription?.onPostgresChanges(
        schema: publicSchema,
        table: _backendTables[syncable],
        event: PostgresChangeEvent.all,
        callback: (p) {
         // This is wrong... prints out a doubly hex-encoded string binary...
         print(_hexToBytes(p['data']));
        },

The resulting record has a double encoded field, leading me to manually patch it every time which seems wrong.

To Reproduce
Steps to reproduce the behavior:

  1. Start a Realtime subscription on a table with bytea column.
  2. Add a new record.
  3. Print the bytea column.

Expected behavior
A hex representation of the binary data in the table.

Actual
A hex representation of the hex representation of the binary data in the table.

Screenshots
If applicable, add screenshots to help explain your problem.
N/A

Version (please complete the following information):

├── supabase_flutter 2.9.0
│   ├── supabase 2.7.0
│   │   ├── functions_client 2.4.2
│   │   ├── gotrue 2.12.0
│   │   ├── postgrest 2.4.2
│   │   ├── realtime_client 2.5.0
│   │   ├── storage_client 2.4.0

Additional context
Add any other context about the problem here.

This may be server related and not SDK-specific.

@gagik gagik added the bug Something isn't working label Jun 1, 2025
@dshukertjr dshukertjr added the realtime This issue or pull request is related to realtime label Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working realtime This issue or pull request is related to realtime
Projects
None yet
Development

No branches or pull requests

2 participants