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

[Bug]: Table 'bookingReference' can't use a non-unique index without a primary index #32

Open
waptik opened this issue Jul 27, 2023 · 6 comments

Comments

@waptik
Copy link
Contributor

waptik commented Jul 27, 2023

So i came across some serious bug which i think it is. I was moving forward with my project when i noticed an error while querying an index field. I thought it was some code error on my part but i found no error after hours of searching.
So i updated my demo example and tried it there after updating to latest version.
At this location, https://github.com/waptik/test-deno-pentagon/blob/main/main.ts#L67, you can replace the value of meetingId with crypto.randomUUID() and you'll still get the error found in the screenshot.
If you remove .describe('index') from https://github.com/waptik/test-deno-pentagon/blob/main/db.ts#L80 and save the file, the code will run perfectly without errors.

image

@skoshx
Copy link
Owner

skoshx commented Jul 29, 2023

Hello, thanks for opening this issue, will investigate!

@waptik
Copy link
Contributor Author

waptik commented Jul 29, 2023

Hello, thanks for opening this issue, will investigate!

Okay, looking forward to a positive outcome

@skoshx
Copy link
Owner

skoshx commented Jul 30, 2023

Hello,

I'm curious to understand your use of index for meetingId in this example.

export const BookingReference = z
  .object({
    id: z
      .string()
      .uuid()
      .describe("primary")
      .default(() => generateUUID()),
    type: z.string().min(1),
    bookingId: z.string().uuid().optional(),
    meetingId: z.string().uuid().describe("index").optional(),
    meetingUrl: z.string().url().optional(),
    meetingPassword: z.string().optional(),
  })
  .merge(WithDefautTimestamps);

Why is the meetingId indexed, when it can also be optional? The use of indexed keys is basically to improve querying speed of many different entries that have the matching indexed key value. So for example; if you had a million users with a indexed key favoriteColor, and indexed key would make it faster to search the users that have eg favoriteColor: 'yellow'

So I'm curious to understand the use-case here, with an optional indexed key?

@waptik
Copy link
Contributor Author

waptik commented Jul 30, 2023 via email

@skoshx
Copy link
Owner

skoshx commented Jul 30, 2023

Okay, I see. I think in this case the meetingId shouldn't be an indexed key, because it doesn't really help in performance unless there are many bookings with the same meetingId (I think it would have to be hundreds of bookings to make performance difference).

If everything works fine without the index, I think then just removing it is the best solution for now!

@waptik
Copy link
Contributor Author

waptik commented Jul 31, 2023

Okay, i've removed the index for now after opening this issue but i still think this should be looked into.
Right now, there's no way for the app to have hundreds of bookings and meetingId (event ids) so it's no big deal for now when index isn't present.

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

No branches or pull requests

2 participants