dynamoid icon indicating copy to clipboard operation
dynamoid copied to clipboard

querying returns a different table name, GSI in dynamoDB

Open deeksha1812 opened this issue 5 years ago • 6 comments

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!!

deeksha1812 avatar Nov 23 '20 15:11 deeksha1812

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?

andrykonchin avatar Nov 23 '20 17:11 andrykonchin

When I query to fetch some record, looking at the dynamodb in logs it looks for incorrect table and throws non existent table error

On Mon, 23 Nov, 2020, 11:18 pm Andrew Konchin, [email protected] wrote:

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?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Dynamoid/dynamoid/issues/474#issuecomment-732321205, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARUIPZKFFSQ4IKPMWJLI5D3SRKN63ANCNFSM4T7UUZ5Q .

deeksha1812 avatar Nov 23 '20 17:11 deeksha1812

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.

andrykonchin avatar Nov 24 '20 10:11 andrykonchin

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"

pbzymek avatar Dec 01 '20 07:12 pbzymek

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.

andrykonchin avatar Dec 01 '20 19:12 andrykonchin

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.

pbzymek avatar Dec 02 '20 11:12 pbzymek