Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync issues when using more than 2 conditions in where clause #2224

Closed
godiagonal opened this issue Jan 13, 2025 · 4 comments
Closed

Sync issues when using more than 2 conditions in where clause #2224

godiagonal opened this issue Jan 13, 2025 · 4 comments
Assignees
Labels

Comments

@godiagonal
Copy link

godiagonal commented Jan 13, 2025

There seems to be a limitation to the number of conditions allowed in where clauses. I can't find anything in the docs that indicate that this is expected behavior.

When my where clause contains one or two conditions the syncing works as expected.

const shape = useShape({
  url: 'http://localhost/v1/shape',
  params: {
    table: 'activity',
    // Works as expected
    where: `team_id = '${teamId}' AND deleted_at IS NULL`
  },
});

But when I add a third condition (which is inevitable for my use case) the shape becomes "stale". It doesn't update even though the underlying table data is updated.

const shape = useShape({
  url: 'http://localhost/v1/shape',
  params: {
    table: 'activity',
    // Does not work
    where: `team_id = '${teamId}' AND deleted_at IS NULL and archived = false`
  },
});

I've tried arranging conditions in different order and combinations but concluded that it's the number of conditions (>= 3) that result in sync issues. Also tried using replica: 'full' but it didn't make a difference.

Is this a known limitation or a bug?

@robacourt robacourt self-assigned this Jan 13, 2025
@robacourt
Copy link
Contributor

It is a bug. I've just reproduced it. I'm working on a fix now

@balegas balegas added the bug label Jan 13, 2025
@robacourt
Copy link
Contributor

While you're waiting for the bug fix, a workaround is to use brackets:

where: `team_id = '${teamId}' AND (deleted_at IS NULL and archived = false)`

@robacourt
Copy link
Contributor

This is now fixed in version 1.0.0-beta.4

@godiagonal
Copy link
Author

Thanks for the quick fix @robacourt!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants