-
Notifications
You must be signed in to change notification settings - Fork 433
Return the correct last_evaluated_key for limited queries/scans. Fixes #406 #410
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
Conversation
pynamodb/pagination.py
Outdated
| last_evaluated_key[key] = item[key] | ||
| else: | ||
| # Use the table meta data to determine the key attributes | ||
| table_connection = self.page_iter._operation.im_self |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we write a private method to expose this? do we need this other places in the file?
pynamodb/pagination.py
Outdated
| else: | ||
| # Use the table meta data to determine the key attributes | ||
| table_connection = self.page_iter._operation.im_self | ||
| table_meta = table_connection.connection.get_meta_table(table_connection.table_name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same
18b2f71 to
ac35cb5
Compare
pynamodb/connection/base.py
Outdated
| Returns the names of the primary key attributes and index key attributes (if index_name is specified) | ||
| """ | ||
| key_names = [self.hash_keyname] | ||
| range_keyname = self.range_keyname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self.range_keyname:
key_names.append(self.range_keyname)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would require us to search for it twice if it doesn't exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
search? twice? it's only used once in this method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.range_keyname is a property computed by scanning the metadata -- its memoized, but only if the value is not None -- if it is None, the if statement will search and then ....
actually you're right, if it's None you won't enter the if block -- updating
| range_keyname = self.range_keyname | ||
| if range_keyname is not None: | ||
| key_names.append(range_keyname) | ||
| if index_name is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there not more than one index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to get the keys on a per-index basis since they are different for each index
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think that's what i'm asking... shouldn't there be a loop here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the function (as written) returns keys for a specific index (or for the table if no index is specified), not all combinations for all indexes
95ed732 to
f1450e5
Compare
f1450e5 to
11f84ef
Compare
| break | ||
| return self._hash_keyname | ||
|
|
||
| def get_key_names(self, index_name=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add some tests for this
No description provided.