-
-
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.
Merge pull request #282 from psteinroe/fix/nested-query
fix: refactor fetchers to dedupe paths and normalise the response
- Loading branch information
Showing
44 changed files
with
754 additions
and
373 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,7 @@ | ||
--- | ||
"@supabase-cache-helpers/postgrest-core": patch | ||
"@supabase-cache-helpers/postgrest-react-query": patch | ||
"@supabase-cache-helpers/postgrest-swr": patch | ||
--- | ||
|
||
fix: use flattened object for normalized data to fix bugs with nested joins overlapping with the 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
2 changes: 1 addition & 1 deletion
2
...ests__/lib/build-select-statement.spec.ts → ...ts__/fetch/build-select-statement.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
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,16 @@ | ||
import { buildDedupePath } from '../../src/fetch/dedupe'; | ||
|
||
describe('buildDedupePath', () => { | ||
it('should apply alias to nested path correctly', () => { | ||
expect( | ||
buildDedupePath(0, { | ||
path: 'note_id.relation_id', | ||
declaration: 'note_id.relation_id', | ||
}) | ||
).toMatchObject({ | ||
path: 'note_id.relation_id', | ||
declaration: 'note_id.d_0_relation_id:relation_id', | ||
alias: 'note_id.d_0_relation_id', | ||
}); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
packages/postgrest-core/__tests__/filter/denormalize.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,29 @@ | ||
import { denormalize } from '../../src/filter/denormalize'; | ||
import { parseSelectParam } from '../../src/lib/parse-select-param'; | ||
|
||
describe('denormalize', () => { | ||
it('should work with nested alias', () => { | ||
const paths = parseSelectParam( | ||
'note_id(test,relation_id,rel:relation_id(test))' | ||
); | ||
|
||
expect( | ||
denormalize(paths, { | ||
test: '123', | ||
some: '456', | ||
value: '789', | ||
'note_id.test': '123', | ||
'note_id.relation_id': 'id', | ||
'note_id.relation_id.test': '345', | ||
}) | ||
).toEqual({ | ||
note_id: { | ||
test: '123', | ||
relation_id: 'id', | ||
rel: { | ||
test: '345', | ||
}, | ||
}, | ||
}); | ||
}); | ||
}); |
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,7 @@ | ||
import * as Import from '../src'; | ||
|
||
describe('index exports', () => { | ||
it('should export', () => { | ||
expect(Object.keys(Import)).toHaveLength(30); | ||
}); | ||
}); |
Oops, something went wrong.