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

querying returns a different table name, GSI in dynamoDB #474

Open
deeksha1812 opened this issue Nov 23, 2020 · 6 comments
Open

querying returns a different table name, GSI in dynamoDB #474

deeksha1812 opened this issue Nov 23, 2020 · 6 comments

Comments

@deeksha1812
Copy link

I am using dynamoid gem 3.6.0. I have a model and have GSI on one of its fields.When I query that table to fetch records of that field, it seems to use incorrect table name.
Please help!!

@andrykonchin
Copy link
Member

Could you please provide an example to reproduce the issue?

it seems to use incorrect table name.

Could you please clarify how you did determine that the table name is wrong?

@deeksha1812
Copy link
Author

deeksha1812 commented Nov 23, 2020 via email

@andrykonchin
Copy link
Member

Could you provide some code to reproduce the issue? We need at least the model class (field and table declarations) and how to query a table to reproduce the error.

@pbzymek
Copy link

pbzymek commented Dec 1, 2020

Hey, I run into the same issue, I was able to reproduce it with the code below:

require 'dynamoid'

class LoggableEvent
  include ::Dynamoid::Document

  table name: :loggable_events

  field :event_object, :serialized
end

LoggableEvent.table
 => nil
LoggableEvent.table_name
 => "dynamoid_app_development_loggableevents"  
# while the expected should be "dynamoid_app_development_loggable_events"

@andrykonchin
Copy link
Member

It's quite an expected behavior as far as table method is called twice:

# first time
  table name: :loggable_events

# second time
LoggableEvent.table
# => nil

The second call overrides the table configuration and specified name loggable_events.

@pbzymek
Copy link

pbzymek commented Dec 2, 2020

I guess this makes sense. That said, this might be a hint why in some edge cases there might be an incorrect table name used when querying DynamoDB.

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

3 participants