stevearc / flywheel

Object mapper for Amazon's DynamoDB
MIT License
128 stars 25 forks source link

Add optional kwarg 'attribute_name' to Field #19

Closed numberoverzero closed 9 years ago

numberoverzero commented 10 years ago

Implements most of #16 (doesn't handle conflicts)

attribute_name, if defined, will be used as the column name in AWS DynamoDB, while the field will still be bound to the model by its name. For example:

class MyModel(Model):
    field = Field(attribute_name='f', hash_key=True)

m = MyModel('uuid')
print(m.field)  # Prints 'uuid'
get_engine().save(m, overwrite=True)

The table for this model in AWS DynamoDB would have hash key 'f'.

coveralls commented 10 years ago

Coverage Status

Coverage increased (+0.08%) when pulling 52d187e79f0ff8e44b8dcd16e99ad6357d352794 on numberoverzero:master into 3430ae4b73fb62cd9c6f132f0c13c7e1918c5387 on mathcamp:master.

stevearc commented 10 years ago

This is a good start, but it's incomplete. I think that all parts of the code that interface with dynamo3 will have to be changed, and we'll need to add a lot of tests to make sure these fields work for everything. For example, if you try to atomically increment an aliased field model.incr_(field_name=2), it will do the wrong thing.