Skip to content

Commit

Permalink
fix(supabase): change default value of meta.select to "*" (#5841)
Browse files Browse the repository at this point in the history
Co-authored-by: Ali Emir Şen <senaliemir@gmail.com>
  • Loading branch information
issa012 and aliemir committed Apr 25, 2024
1 parent 9a0c1c8 commit 7b13515
Show file tree
Hide file tree
Showing 22 changed files with 2,538 additions and 1,204 deletions.
5 changes: 5 additions & 0 deletions .changeset/neat-oranges-begin.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@refinedev/supabase": patch
---

fix: in methods update, updateMany, create, createMany, meta.select changed to "\*". Resolves #5679
16 changes: 4 additions & 12 deletions packages/supabase/src/dataProvider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ export const dataProvider = (

const query = client.from(resource).insert(variables);

if (meta?.select) {
query.select(meta.select);
}
query.select(meta?.select ?? "*");

const { data, error } = await query;

Expand All @@ -107,9 +105,7 @@ export const dataProvider = (

const query = client.from(resource).insert(variables);

if (meta?.select) {
query.select(meta.select);
}
query.select(meta?.select ?? "*");

const { data, error } = await query;

Expand All @@ -135,9 +131,7 @@ export const dataProvider = (
query.match({ id });
}

if (meta?.select) {
query.select(meta.select);
}
query.select(meta?.select ?? "*");

const { data, error } = await query;
if (error) {
Expand All @@ -164,9 +158,7 @@ export const dataProvider = (
query.match({ id });
}

if (meta?.select) {
query.select(meta.select);
}
query.select(meta?.select ?? "*");

const { data, error } = await query;
if (error) {
Expand Down
226 changes: 188 additions & 38 deletions packages/supabase/test/create/index.mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,95 @@
import nock from "nock";

nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
encodedQueryParams: true,
})
.post("/auth/v1/token", {
email: "info@refine.dev",
password: "refine-supabase",
gotrue_meta_security: {},
})
.query({ grant_type: "password" })
.reply(
200,
{
access_token:
"eyJhbGciOiJIUzI1NiIsImtpZCI6IldGWnFuOWt6bnBJZTIvL2wiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzE0MDM5MDk1LCJpYXQiOjE3MTQwMzU0OTUsImlzcyI6Imh0dHBzOi8vaXdkZnp2ZnFidG9rcWV0bWJtYnAuc3VwYWJhc2UuY28vYXV0aC92MSIsInN1YiI6ImJkZWZhYzgxLTJiZDEtNDRkMS1iNWVkLTdhYmVkYjk2Y2NjZSIsImVtYWlsIjoiaW5mb0ByZWZpbmUuZGV2IiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCJ9LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJwYXNzd29yZCIsInRpbWVzdGFtcCI6MTcxNDAzNTQ5NX1dLCJzZXNzaW9uX2lkIjoiY2NjMWUzODEtNmFkYS00OTdkLWIxYjAtOWM4ZmJjNWQwYWZmIiwiaXNfYW5vbnltb3VzIjpmYWxzZX0.yVJ6lWNwdQCsbPsP5tfJk7Xjtx2bHRBaiyaox6KcMX0",
token_type: "bearer",
expires_in: 3600,
expires_at: 1714039095,
refresh_token: "R0tQR-e2RgQQdsS7OTMCWQ",
user: {
id: "bdefac81-2bd1-44d1-b5ed-7abedb96ccce",
aud: "authenticated",
role: "authenticated",
email: "info@refine.dev",
email_confirmed_at: "2021-09-08T11:09:24.284171Z",
phone: "",
confirmation_sent_at: "2021-09-08T11:08:06.793257Z",
confirmed_at: "2021-09-08T11:09:24.284171Z",
recovery_sent_at: "2024-02-04T09:33:53.383988Z",
last_sign_in_at: "2024-04-25T08:58:15.046729193Z",
app_metadata: { provider: "email" },
user_metadata: {},
identities: [
{
identity_id: "6b8dcf5b-f068-401b-95ae-ddd93d771b74",
id: "bdefac81-2bd1-44d1-b5ed-7abedb96ccce",
user_id: "bdefac81-2bd1-44d1-b5ed-7abedb96ccce",
identity_data: {
email: "info@refine.dev",
sub: "bdefac81-2bd1-44d1-b5ed-7abedb96ccce",
},
provider: "email",
last_sign_in_at: "2022-11-25T00:00:00Z",
created_at: "2022-11-25T00:00:00Z",
updated_at: "2022-11-25T00:00:00Z",
email: "info@refine.dev",
},
],
created_at: "2021-09-08T11:08:06.789274Z",
updated_at: "2024-04-25T08:58:15.04881Z",
is_anonymous: false,
},
},
[
"Date",
"Thu, 25 Apr 2024 08:58:15 GMT",
"Content-Type",
"application/json",
"Transfer-Encoding",
"chunked",
"Connection",
"close",
"CF-Ray",
"879d21512ac6519b-IST",
"CF-Cache-Status",
"DYNAMIC",
"Access-Control-Allow-Origin",
"*",
"Set-Cookie",
"sb-access-token=eyJhbGciOiJIUzI1NiIsImtpZCI6IldGWnFuOWt6bnBJZTIvL2wiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJhdXRoZW50aWNhdGVkIiwiZXhwIjoxNzE0MDM5MDk1LCJpYXQiOjE3MTQwMzU0OTUsImlzcyI6Imh0dHBzOi8vaXdkZnp2ZnFidG9rcWV0bWJtYnAuc3VwYWJhc2UuY28vYXV0aC92MSIsInN1YiI6ImJkZWZhYzgxLTJiZDEtNDRkMS1iNWVkLTdhYmVkYjk2Y2NjZSIsImVtYWlsIjoiaW5mb0ByZWZpbmUuZGV2IiwicGhvbmUiOiIiLCJhcHBfbWV0YWRhdGEiOnsicHJvdmlkZXIiOiJlbWFpbCJ9LCJ1c2VyX21ldGFkYXRhIjp7fSwicm9sZSI6ImF1dGhlbnRpY2F0ZWQiLCJhYWwiOiJhYWwxIiwiYW1yIjpbeyJtZXRob2QiOiJwYXNzd29yZCIsInRpbWVzdGFtcCI6MTcxNDAzNTQ5NX1dLCJzZXNzaW9uX2lkIjoiY2NjMWUzODEtNmFkYS00OTdkLWIxYjAtOWM4ZmJjNWQwYWZmIiwiaXNfYW5vbnltb3VzIjpmYWxzZX0.yVJ6lWNwdQCsbPsP5tfJk7Xjtx2bHRBaiyaox6KcMX0; Path=/; Expires=Fri, 26 Apr 2024 08:58:15 GMT; Max-Age=86400; HttpOnly; Secure",
"Strict-Transport-Security",
"max-age=15552000; includeSubDomains",
"Vary",
"Accept-Encoding, Origin",
"Via",
"kong/2.8.1",
"sb-gateway-version",
"1",
"Set-Cookie",
"sb-refresh-token=R0tQR-e2RgQQdsS7OTMCWQ; Path=/; Expires=Fri, 26 Apr 2024 08:58:15 GMT; Max-Age=86400; HttpOnly; Secure",
"x-kong-proxy-latency",
"1",
"x-kong-upstream-latency",
"90",
"Server",
"cloudflare",
"alt-svc",
'h3=":443"; ma=86400',
],
);

nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
encodedQueryParams: true,
})
Expand All @@ -8,64 +98,85 @@ nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
slug: "foo-bar",
content: "bar",
categoryId: 2,
image: {},
})
.matchHeader("Prefer", "return=representation")
.query({ select: "*" })
.query({ select: "%2A" })
.reply(
201,
[
{
id: 33,
id: 12893,
title: "foo",
slug: "foo-bar",
createdAt: "2021-09-06T09:50:17.716058+00:00",
createdAt: "2024-04-25T08:58:15.561287+00:00",
content: "bar",
categoryId: 2,
image: {},
images: null,
},
],
[
"Date",
"Thu, 25 Apr 2024 08:58:15 GMT",
"Content-Type",
"application/json; charset=utf-8",
"Transfer-Encoding",
"chunked",
"Connection",
"close",
"Date",
"Mon, 06 Sep 2021 09:50:17 GMT",
"Server",
"postgrest/8.0.0",
"Location",
"/posts?id=eq.33",
"Content-Range",
"*/*",
"Content-Profile",
"public",
"vary",
"Origin",
"CF-Ray",
"879d2155cf286970-IST",
"CF-Cache-Status",
"DYNAMIC",
"Access-Control-Allow-Origin",
"*",
"X-Kong-Upstream-Latency",
"4",
"X-Kong-Proxy-Latency",
"1",
"Strict-Transport-Security",
"max-age=15552000; includeSubDomains",
"Via",
"kong/2.2.1",
"kong/2.8.1",
"content-profile",
"public",
"sb-gateway-version",
"1",
"x-kong-proxy-latency",
"3",
"x-kong-upstream-latency",
"7",
"Vary",
"Accept-Encoding",
"Server",
"cloudflare",
"alt-svc",
'h3=":443"; ma=86400',
],
);

nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
encodedQueryParams: true,
})
.post("/rest/v1/products", { name: "foo" })
.post("/rest/v1/posts", {
title: "foo",
slug: "foo-bar",
content: "bar",
categoryId: 2,
})
.query({ select: "%2A" })
.reply(
201,
[{ id: 19, name: "foo" }],
[
{
id: 12894,
title: "foo",
slug: "foo-bar",
createdAt: "2024-04-25T08:58:15.88472+00:00",
content: "bar",
categoryId: 2,
images: null,
},
],
[
"Date",
"Tue, 23 Jan 2024 11:54:21 GMT",
"Thu, 25 Apr 2024 08:58:15 GMT",
"Content-Type",
"application/json; charset=utf-8",
"Transfer-Encoding",
Expand All @@ -75,23 +186,23 @@ nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
"Content-Range",
"*/*",
"CF-Ray",
"849fd76c0a25733a-BUD",
"879d21585813724e-IST",
"CF-Cache-Status",
"DYNAMIC",
"Access-Control-Allow-Origin",
"*",
"Strict-Transport-Security",
"max-age=2592000; includeSubDomains",
"max-age=15552000; includeSubDomains",
"Via",
"kong/2.8.1",
"Content-Profile",
"content-profile",
"public",
"sb-gateway-version",
"1",
"X-Kong-Proxy-Latency",
"1",
"X-Kong-Upstream-Latency",
"6",
"x-kong-proxy-latency",
"0",
"x-kong-upstream-latency",
"7",
"Vary",
"Accept-Encoding",
"Server",
Expand All @@ -104,7 +215,8 @@ nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
encodedQueryParams: true,
})
.post("/rest/v1/products", {})
.post("/rest/v1/posts", {})
.query({ select: "%2A" })
.reply(
406,
{
Expand All @@ -115,29 +227,29 @@ nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
},
[
"Date",
"Tue, 23 Jan 2024 12:06:17 GMT",
"Thu, 25 Apr 2024 08:58:16 GMT",
"Content-Type",
"application/json; charset=utf-8",
"Transfer-Encoding",
"chunked",
"Connection",
"close",
"CF-Ray",
"849fe8e499a068bb-BUD",
"879d2159d8847212-IST",
"CF-Cache-Status",
"DYNAMIC",
"Access-Control-Allow-Origin",
"*",
"Strict-Transport-Security",
"max-age=2592000; includeSubDomains",
"max-age=15552000; includeSubDomains",
"Via",
"kong/2.8.1",
"sb-gateway-version",
"1",
"X-Kong-Proxy-Latency",
"0",
"X-Kong-Upstream-Latency",
"x-kong-proxy-latency",
"1",
"x-kong-upstream-latency",
"0",
"Vary",
"Accept-Encoding",
"Server",
Expand All @@ -146,3 +258,41 @@ nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
'h3=":443"; ma=86400',
],
);

nock("https://iwdfzvfqbtokqetmbmbp.supabase.co:443", {
encodedQueryParams: true,
})
.post("/auth/v1/logout")
.query({ scope: "global" })
.reply(204, "", [
"Date",
"Thu, 25 Apr 2024 08:58:16 GMT",
"Connection",
"close",
"CF-Ray",
"879d215b9ec65184-IST",
"CF-Cache-Status",
"DYNAMIC",
"Access-Control-Allow-Origin",
"*",
"Set-Cookie",
"sb-access-token=; Path=/; Expires=Wed, 24 Apr 2024 22:58:16 GMT; Max-Age=0; HttpOnly; Secure",
"Strict-Transport-Security",
"max-age=15552000; includeSubDomains",
"Vary",
"Origin, Accept-Encoding",
"Via",
"kong/2.8.1",
"sb-gateway-version",
"1",
"Set-Cookie",
"sb-refresh-token=; Path=/; Expires=Wed, 24 Apr 2024 22:58:16 GMT; Max-Age=0; HttpOnly; Secure",
"x-kong-proxy-latency",
"1",
"x-kong-upstream-latency",
"11",
"Server",
"cloudflare",
"alt-svc",
'h3=":443"; ma=86400',
]);

0 comments on commit 7b13515

Please sign in to comment.