Dynamoid / dynamoid

Ruby ORM for Amazon's DynamoDB.
MIT License
580 stars 195 forks source link

delete_all method returns Empty attribute name error #580

Closed manhbuithe closed 2 years ago

manhbuithe commented 2 years ago

This is my table setting:

table(
    name: :test_admin_request_logs,
    read_capacity: 5,
    write_capacity: 100
  )
  field :created_date
  field :admin_user_id, :integer
  field :admin_user_email
  field :url
  field :ip
  field :user_agent
  field :http_method
  field :parameters
  global_secondary_index(
    hash_key: :created_date,
    range_key: :created_at,
    projected_attributes: :all,
    read_capacity: 5,
    write_capacity: 100
  )
  range :created_at, :integer

I tried to delete record by this command RequestLog.where(id: "cc3e3fhy-7ae7-43c5-8cf2-2d32434e6c80").delete_all

But the request I captured contained the empty key. It seems to be the value of created_at

{
  "RequestItems":{
      "remitano_application_development_test_admin_request_logs":[
          {
              "DeleteRequest":{
                  "Key":{
                      "id":{
                          "S":"1-7ae7-43c5-8cf2-2d32434e6c80"
                      },
                      "":{
                          "N":"1657698332.0"
                      }
                  }
              }
          }
      ]
  },
  "ReturnConsumedCapacity":"TOTAL",
  "ReturnItemCollectionMetrics":"SIZE"
}

So it showed Empty attribute name error.

manhbuithe commented 2 years ago

Closed. Because of range : created_at