Skip to content
This repository has been archived by the owner on May 13, 2023. It is now read-only.

Int column turned to String in realtime listening (for one row) #68

Closed
bit-burger opened this issue Dec 1, 2021 · 6 comments
Closed
Labels
bug Something isn't working duplicate This issue or pull request already exists

Comments

@bit-burger
Copy link

Bug report

Describe the bug

After getting the RealtimeSubscription Unhandled Exception: type 'Null' is not a subtype of type 'List' in type cast error and fixing it, im fed up again, if I get realtime data from my user profile (which is discriminated with the :id=eq.$userId) every column that is an int gets converted to a String in dart;

To Reproduce

Pretty much said this, just need a table, and listen two only two one row, and all int columns won't be int in dart but a string

Expected behaviour

Obviously not have an error with the type conversion

Screenshots

If applicable, add screenshots to help explain your problem.

System information

  • OS: [e.g. macOS, Windows]
  • Browser (if applies) [e.g. chrome, safari]
  • Version of supabase-dart: newest (the one with the pull request)

Additional context

Please don't always roll out breaking changes, literally everything is breaking on this update.

@bit-burger bit-burger added the bug Something isn't working label Dec 1, 2021
@bdlukaa
Copy link
Contributor

bdlukaa commented Dec 1, 2021

Duplicate of #64.

Also, could you not create another issue with the same information?

@bdlukaa bdlukaa closed this as completed Dec 1, 2021
@bdlukaa bdlukaa added the duplicate This issue or pull request already exists label Dec 1, 2021
@bit-burger
Copy link
Author

@bdlukaa Sry accidentally sent it two times because i had duplicated the tab, won't happen again!

@bit-burger
Copy link
Author

But i am failing to understand how this is a duplicate, no one mentions int columns or whatever type being changed to String columns, I even have overridden my dependencies with that exact branch of Supabase before it was merged, because before that nothing worked and after the installing of that branch there were the issues with the String columns, so it is definitely not fixed

@bdlukaa
Copy link
Contributor

bdlukaa commented Dec 3, 2021

RealtimeSubscription Unhandled Exception: type 'Null' is not a subtype of type 'List' in type cast error

I assumed the issue was with this.

@bit-burger
Copy link
Author

Here a small bit of code to maybe better understand the problem:

create domain points as bigint check (value >= 0);
create domain color as smallint check ((value >= 0) and (value < 10));
create domain icon as smallint check ((value >= 0) and (value < 230));

create table public.profiles(
  id uuid primary key references auth.users on delete cascade,
  name varchar(8) not null check(name ~ '^(?!-|\s)([a-z-]|\s)*[a-z]$'),
  status varchar(16) not null default 'im new to points',
  bio varchar(256) not null,
  color color not null default 9,
  icon icon not null default 0,
  points points not null default 0,
  gives points not null default 0
);
_client.from("profiles:id=eq.$userId").on(
        SupabaseEventTypes.update,
        (payload) {
          final user = payload.newRecord!;
          // TODO: Temp fix
          if (user["color"] is String) {
            user["color"] = int.parse(user["color"]);
          }
          if (user["icon"] is String) {
            user["icon"] = int.parse(user["icon"]);
          }
          if (user["points"] is String) {
            user["points"] = int.parse(user["points"]);
          }
          if (user["gives"] is String) {
            user["gives"] = int.parse(user["gives"]);
          }
          // Now the user can actually be used
        },
      )

As you can see I have to convert each and every column (I put them in ifs checking the type incase Supabase changes again)

@bit-burger
Copy link
Author

@bdlukaa yes im sorry for not making it directly clear

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants