diff --git a/.changeset/fifty-oranges-poke.md b/.changeset/fifty-oranges-poke.md new file mode 100644 index 00000000..b6400481 --- /dev/null +++ b/.changeset/fifty-oranges-poke.md @@ -0,0 +1,5 @@ +--- +"@supabase-cache-helpers/postgrest-core": patch +--- + +fix: dont include wildcards from cache query diff --git a/packages/postgrest-core/src/fetch/build-normalized-query.ts b/packages/postgrest-core/src/fetch/build-normalized-query.ts index 488cc6eb..175881b2 100644 --- a/packages/postgrest-core/src/fetch/build-normalized-query.ts +++ b/packages/postgrest-core/src/fetch/build-normalized-query.ts @@ -89,7 +89,9 @@ export const buildNormalizedQuery = ({ removeAliasFromDeclaration(path.declaration), ) && // do not add agg functions - !path.declaration.endsWith('.count') + !path.declaration.endsWith('.count') && + // do not add wildcard queries + !path.declaration.endsWith('*') ) { paths.push({ path: path.path, diff --git a/packages/postgrest-core/tests/fetch/build-mutation-fetcher-response.spec.ts b/packages/postgrest-core/tests/fetch/build-mutation-fetcher-response.spec.ts index da5fd40e..d5c413ea 100644 --- a/packages/postgrest-core/tests/fetch/build-mutation-fetcher-response.spec.ts +++ b/packages/postgrest-core/tests/fetch/build-mutation-fetcher-response.spec.ts @@ -94,7 +94,7 @@ describe('buildMutationFetcherResponse', () => { }); }); - it('should work with wildcard', () => { + it('should include wildcard from user query only', () => { const q = c .from('contact') .select('some,value,ishouldbetheretoo,*,note_id(id,test,*)') @@ -119,7 +119,7 @@ describe('buildMutationFetcherResponse', () => { note_id: { id: 'id', test: '123', - ishouldalsobethere: 'id', + ishouldnotbethere: 'id', }, }, { @@ -137,7 +137,6 @@ describe('buildMutationFetcherResponse', () => { 'ishouldbetheretootootoo.0.one': 'two', 'note_id.id': 'id', 'note_id.test': '123', - 'note_id.ishouldalsobethere': 'id', }, userQueryData: { some: '456',