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

eq not working on apikey column #5465

Closed
skwasan opened this issue Feb 15, 2022 · 3 comments
Closed

eq not working on apikey column #5465

skwasan opened this issue Feb 15, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@skwasan
Copy link

skwasan commented Feb 15, 2022

Bug report

Supabase eq not working

Describe the bug

 const { data, error } = await supabase
    .from('userdetails')
    .select()
    .eq('apikey', 'no-apikey-in-db') //This returns all the rows in table which is not correct as apikey is not in db

My data for select is

data: [
{
id: "e23222a4-b061-4ca1-8a2a-99ec3674a9c9",
username: "sdf sdfds",
email: "sddsf@gmsil.com",
apikey: "dde7ceb7d7dc4e569f56b1300d9c267b",
updated_at: null,
created_at: "2022-02-15T03:54:54.490956+00:00",
config: null
},
{
id: "e52304a3-05f1-4d46-b491-da61a12726ee",
username: "abc",
email: "abc@gmail.com",
apikey: "1f6156a4abc8483085a3d208e25a209e",
updated_at: "2022-02-15T05:24:58.324911+00:00",
created_at: "2022-02-15T03:30:20.634416+00:00",
config: {..}]

This is how I created the table

create table userdetails (
  id uuid references auth.users not null,
  username text,
  email text,
  apikey VARCHAR DEFAULT REPLACE(uuid_generate_v4()::text, '-', '' ),
  updated_at TIMESTAMP WITH TIME ZONE,
  primary key (id)
);

It's working for all the other keys but not apikey say email.

 const { data, error } = await supabase
    .from('userdetails')
    .select()
    .eq('email', 'no-apikey-in-db') //This returns 0 rows which is correct

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

Please create above table and add data give above

Expected behavior

0 Rows should be returned as no rows in db matches no-apikey-db. But eq returns all the rows

A clear and concise description of what you expected to happen.

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-js: [e.g. 6.0.2]
  • Version of Node.js: [e.g. 10.10.0]

Additional context

Add any other context about the problem here.

@skwasan skwasan added the bug Something isn't working label Feb 15, 2022
@steve-chavez
Copy link
Member

I think this happens because the Kong gateway(reached before PostgREST on Supabase instances) uses the apikey query parameter, likely it's not passing apikey to PostgREST.

Not ideal, but a workaround could be renaming your apikey column to something else, like user_apikey.

@steve-chavez steve-chavez changed the title Supabase eq not working eq not working on apikey column Feb 15, 2022
@skwasan
Copy link
Author

skwasan commented Feb 15, 2022

Thanks, It resolved but its really bad. I spent so much time banging my head to wall 😁

awalias added a commit that referenced this issue Feb 16, 2022
@awalias
Copy link
Member

awalias commented Feb 16, 2022

I've documented it for now, eventually we will move apikey out of the query params for the api gateway, we still need it for now because the realtime server can't yet receive it via headers

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

No branches or pull requests

3 participants