-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: enrich filter paths with declaration from query paths
- Loading branch information
Showing
5 changed files
with
56 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@supabase-cache-helpers/postgrest-core": patch | ||
--- | ||
|
||
fix: enrich parsed filter paths with declaration from query paths |
28 changes: 28 additions & 0 deletions
28
packages/postgrest-core/__tests__/lib/extract-paths-from-filters.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { SupabaseClient, createClient } from '@supabase/supabase-js'; | ||
|
||
import { extractPathsFromFilters } from '../../src/lib/extract-paths-from-filter'; | ||
import { PostgrestParser } from '../../src/postgrest-parser'; | ||
|
||
describe('extractPathsFromFilters', () => { | ||
let c: SupabaseClient; | ||
|
||
beforeAll(() => { | ||
c = createClient('https://localhost', '1234'); | ||
}); | ||
|
||
it('should add declarations from path to matching filter path', () => { | ||
const parser = new PostgrestParser( | ||
c | ||
.from('conversation') | ||
.select('inbox:inbox_id!inner(id,name,emoji)') | ||
.eq('inbox_id.id', 'inbox-id'), | ||
); | ||
expect(extractPathsFromFilters(parser.filters, parser.paths)).toEqual([ | ||
{ | ||
alias: 'inbox.id', | ||
declaration: 'inbox:inbox_id!inner.id', | ||
path: 'inbox_id.id', | ||
}, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters