pynamodb / PynamoDB

A pythonic interface to Amazon's DynamoDB
http://pynamodb.readthedocs.io
MIT License
2.46k stars 427 forks source link

Can we add the option `return_raw_data`? #553

Open o-kaylee opened 6 years ago

o-kaylee commented 6 years ago

Hello,

While I am using this great library, I came to need to retrieve raw data itself. So if we can add return_raw_data option for operations which returns item (e.g., get, batch_get, scan ... ), I think it will be helpful for using flexibility of DynamoDB schemaless characteristic.

I'll introduce an example situation:

class SampleModel(Model):
   id = UnicodeAttribute()
   document = MapAttribute()

and if you want to change attribute data type of document to,

class SampleModel(Model):
   id = UnicodeAttribute()
   document = NumberAttribute()  # changed attribute data type

This changed model will produce TypeError: string indices must be integers on Model.from_raw_data() since this should be returned as integer from botocore.

For resolving this, you have to update all document attribute of all items as newly changed attribute type.

I think return_raw_data option can handle this issue, without migration. I will PR regarding on this issue in short period of term.

m-melis commented 4 days ago

We are also struggling updating the type of attributes, so this will be great!