Skip to content

Commit

Permalink
Merge pull request #484 from sultson/fix/nested-embeddings-parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
psteinroe authored Jul 13, 2024
2 parents f7b72b5 + 6eadac5 commit 073a4d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changeset/lazy-bananas-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
"@supabase-cache-helpers/postgrest-core": patch
---
11 changes: 10 additions & 1 deletion packages/postgrest-core/src/lib/parse-select-param.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ export const parseSelectParam = (s: string, currentPath?: Path): Path[] => {

let result;
try {
result = XRegExp.matchRecursive(`,${s}`, ',[^,]*\\(', '\\)', 'g', {
result = XRegExp.matchRecursive(`,${s}`, '([^,\\(]+)\\(', '\\)', 'g', {
valueNames: {
'0': null,
'1': 'tableName',
'2': 'selectedColumns',
'3': null,
},
}).map((item) => {
if (
item.name === 'tableName' &&
item.value &&
!item.value.startsWith(',')
) {
item.value = ',' + item.value;
}
return item;
});
} catch (e) {
const path = currentPath?.path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('parseSelectParam', () => {
it('should work for special case', () => {
expect(
parseSelectParam(
'id,team_members:team_member_team_id_fkey(team_id,employee!team_member_employee_id_fkey(id,display_name,user_id))',
'id,team_members:team_member_team_id_fkey(employee!team_member_employee_id_fkey(id,display_name,user_id),team_id)',
),
).toEqual([
{
Expand Down

0 comments on commit 073a4d2

Please sign in to comment.