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

Sometimes requires two queries to Profile table #456

Closed
JulianSwales opened this issue Apr 28, 2023 · 3 comments · Fixed by supabase/supabase-dart#192
Closed

Sometimes requires two queries to Profile table #456

JulianSwales opened this issue Apr 28, 2023 · 3 comments · Fixed by supabase/supabase-dart#192
Labels
bug Something isn't working

Comments

@JulianSwales
Copy link

JulianSwales commented Apr 28, 2023

Describe the bug
After logging in the next request is to query a profiles table that returns 0 records yet a second query responds correctly with the record.

To Reproduce
Steps to reproduce the behaviour:

      final response = await client.auth.signInWithPassword(
        email: signInForm.control('email').value.toString(),
        password: signInForm.control('password').value.toString(),
      );

      dynamic userResponse = await client
          .from('profiles')
          .select()
          .eq('user_id', response.user?.id);

      if (userResponse.length < 1) {
        userResponse = await client
            .from('profiles')
            .select()
            .eq('user_id', response.user?.id);
        debugPrint('$userResponse');
      }

99% of the time it requires the second query.. Every once in a while it returns the on the first request.

Expected behaviour
I would expect it to return the record the first request. I've had to add the second query so that the app works.

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

Version (please complete the following information):
On Linux/macOS
Please run dart pub deps | grep -E "supabase|gotrue|postgrest|storage_client|realtime_client|functions_client" in your project directory and paste the output here.
| '-- supabase_flutter...
|-- supabase_flutter 1.8.1
| |-- supabase 1.6.3
| | |-- functions_client 1.1.1
| | |-- gotrue 1.5.7
| | |-- postgrest 1.2.3
| | |-- realtime_client 1.0.2
| | |-- storage_client 1.2.5

flutter doctor
[✓] Flutter (Channel stable, 3.3.2, on macOS 13.3.1 22E261 darwin-arm, locale en-CA)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2020.3)
[✓] VS Code (version 1.77.1)
[✓] Connected device (3 available)
[✓] HTTP Host Availability

• No issues found!

On Windows
Please run dart pub deps | findstr "supabase gotrue postgrest storage_client realtime_client functions_client" in your project directory and paste the output here.

Additional context
Add any other context about the problem here.

Thanks, Julian

@JulianSwales JulianSwales added the bug Something isn't working label Apr 28, 2023
@dshukertjr
Copy link
Member

@JulianSwales
Thanks for reporting this. Can reproduce on my end. Will try to get a fix soon.

@dshukertjr
Copy link
Member

@JulianSwales
In the mean while, here is a quick and dirty way to make it work with just one select statement.

await client.auth.signInWithPassword(
  email: signInForm.control('email').value.toString(),
  password: signInForm.control('password').value.toString(),
);

await Future.delayed(Duration.zero);

final data = await client
    .from('profiles')
    .select()
    .eq('user_id', response.user?.id);

@dshukertjr
Copy link
Member

@JulianSwales
We just published a new version for this to fix this bug. Could you upgrade your supabase version with dart pub upgrade supabase command and try your code? It should work as expected without any workarounds.

await client.auth.signInWithPassword(
  email: signInForm.control('email').value.toString(),
  password: signInForm.control('password').value.toString(),
);

final data = await client
    .from('profiles')
    .select()
    .eq('user_id', response.user?.id);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants