-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
One() does not page through the table like All() #248
Comments
If you want to maintain the existing behavior for backward compatibility, how about a new method |
Hello, I agree this is a footgun/bug. It should probably be changed to search until it finds one page with a result. Personally I think that is more important than scanning the whole table for multiple potential results. In hindsight One's main purpose is to call the GetItem API when you give it the primary keys; its Query support was a bit of a hack/"convenience". Sometimes I'll use it to do things like "get the next item after [range key]". If I were to redesign everything I'd probably just split them. |
v2.3.0 has a fix, added some docs to clarify things as well. |
I'll close this for now but please re-open if you find any problems |
When using the
One(&item)
call, I sometimes getErrNotFound
when the same query works in PartiQL. The same query usingAll(&list)
finds the item I expect.vs.
After some investigation, I found that
One()
does not continue scanning the table until it finds an item. It returns an error if the first page finds no results even when there are more pages to scan.I can see why you might argue that it is intentional since the fix would require paging through the whole table to ensure only one match exists, which is less performant than stopping after one page. However, an inconsistent matching behavior seems like a useless feature.
The workaround is to call
All(&list)
and check that a single result is returned, so I will do that for now. However, I can submit a PR if it's a bug.The text was updated successfully, but these errors were encountered: