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

Fix live query UUID #236

Merged
merged 2 commits into from
Apr 20, 2024
Merged

Conversation

tai-kun
Copy link
Contributor

@tai-kun tai-kun commented Apr 20, 2024

Thank you for the great work on this project.

What is the motivation?

I was unable to subscribe to record changes using the live method. After researching, I found the following:

  • Live query ID is verified by z.string().uuid().
  • In actuality, it is decoded as the UUID class, not a string.

What does this change do?

  • Make live queries work.
  • Changing the string type to UUID prevents users from using it incorrectly.

What is your testing strategy?

Add three tests to tests/integration/tests/live.ts:

  1. The test suite "live" checks that the live method returns a UUID class on the WebSocket engine and verifies that live queries work. Also, checks that it fails on the HTTP engine.
  2. The test suite "unsubscribe live" checks whether a subscribed live query can be unsubscribed using the UUID class returned by the live method. As far as the HTTP engine is concerned, it doesn't support this, so we don't test anything.
  3. The test suite "kill" checks whether a subscribed live query can be canceled using the UUID class returned by the live method. As far as the HTTP engine is concerned, it doesn't support this, so we don't test anything.

Is this related to any issues?

N/A

Have you read the Contributing Guidelines?

The driver currently expects a UUID format string for the live query ID. However, it is actually decoded as a UUID class, not a string. Therefore, the live and subscribeLive methods always fail.
There are no tests for live queries. We need to make sure that live and subscribeLive,  unSubscribeLive, kill methods work.
@tai-kun tai-kun requested a review from kearfy as a code owner April 20, 2024 06:04
@kearfy
Copy link
Member

kearfy commented Apr 20, 2024

Great find @tai-kun, and thank you for adding some tests around live queries! Hadn't found the time to add them myself but this is great 😃

@kearfy kearfy merged commit eed3545 into surrealdb:main Apr 20, 2024
@tai-kun tai-kun deleted the bugfix-fix-live-query-uuid branch April 20, 2024 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants