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

FakeDynamo cannot find local index if there are no conditions #115

Open
kylewm opened this issue Feb 20, 2017 · 0 comments
Open

FakeDynamo cannot find local index if there are no conditions #115

kylewm opened this issue Feb 20, 2017 · 0 comments

Comments

@kylewm
Copy link
Contributor

kylewm commented Feb 20, 2017

If I build a query with an index name but without any filter conditons, e.g.

new QueryBuilder()
  .setTableName('Users')
  .setHashKey('userId', ...)
  .setIndexName('isAdmin-index')
  .execute()

FakeDynamo doesn't know which attribute that corresponds to

FakeTable.prototype.query = function(data) {
  var indexedKeyName
  if (data.IndexName) {
    // Global Secondary Index if the index name has three or more
    // parts (separated by '-')
    var indexParts = data.IndexName.split('-')
    var probableGSIIndex = indexParts.length >= 3
    if (probableGSIIndex) {
      return this._queryGlobalSecondaryIndex(data)
    }

    // Extract the range key for Local Secondary Indexes
    for (var key in data.KeyConditions) {
      if (key !== this.primaryKey.hash.name) {
        indexedKeyName = key
      }
    }
  }
  ...

and (silently) fails to find anything as a result.

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

1 participant