Skip to content

Commit

Permalink
Merge pull request #486 from psteinroe/fix/optimize-wildcard
Browse files Browse the repository at this point in the history
  • Loading branch information
psteinroe committed Jul 14, 2024
2 parents c13a17e + 631812a commit 2ee5894
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/fifty-oranges-poke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@supabase-cache-helpers/postgrest-core": patch
---

fix: dont include wildcards from cache query
4 changes: 3 additions & 1 deletion packages/postgrest-core/src/fetch/build-normalized-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export const buildNormalizedQuery = <Q extends string = '*'>({
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,*)')
Expand All @@ -119,7 +119,7 @@ describe('buildMutationFetcherResponse', () => {
note_id: {
id: 'id',
test: '123',
ishouldalsobethere: 'id',
ishouldnotbethere: 'id',
},
},
{
Expand All @@ -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',
Expand Down

0 comments on commit 2ee5894

Please sign in to comment.