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

PynamoDB version 4 Breaking changes #6

Open
DavidM42 opened this issue Oct 8, 2019 · 4 comments
Open

PynamoDB version 4 Breaking changes #6

DavidM42 opened this issue Oct 8, 2019 · 4 comments

Comments

@DavidM42
Copy link

DavidM42 commented Oct 8, 2019

I updated the packages of my project and had problems with the use of this plugin.
I think it's related to the Breaking changes in the major relase 4.0 of pynamodb I installed.
To be honest I am not 100% sure it was this project but I think the changes to pynamodb could cause problems here

@DavidM42
Copy link
Author

DavidM42 commented Nov 4, 2019

I'm now pretty sure that new versions of pynamodb and/or marshmallow break this library
I currently have these versions locked in for my use as some newer combinations don't work:

flask==1.1.0
marshmallow==2.20.3
marshmallow-pynamodb
botocore==1.12.130
pynamodb==3.3.3
flask-smorest==0.18.2

Maybe I'll try to fix the problems caused by pynamodb version 4 changes but any help updating this library would be great

@kycunnin
Copy link

kycunnin commented Jan 5, 2020

Hey David,
I also encountered breaking changes when using pynamodb 4.2.0 and marshmallow 3.3 Looks like 2 things caused the breakage for me:

  1. The removal of the MapAttributeMeta class from pynamodb.attributes
  2. The inclusion of a new kwarg "ordered" for the SchemaOpts class in marshmallow

Not sure if this is the best solution but I was able to get a local version running by changing the mapping in convert.py to import the MapAttribute class instead of the MapAttributeMeta (I'm not sure what the actual effects of this are I'm mostly just doing this to get past the import error)

PYNAMODB_TYPE_MAPPING = {
    attributes.NumberAttribute: fields.Number,
    attributes.JSONAttribute: fields.Raw,
    attributes.UnicodeAttribute: fields.String,
    attributes.BooleanAttribute: fields.Boolean,
    attributes.UTCDateTimeAttribute: fields.DateTime,
    attributes.MapAttribute: custom_fields.PynamoNested,
    attributes.ListAttribute: fields.List,
    attributes.NullAttribute: fields.Raw,
    attributes.UnicodeSetAttribute: custom_fields.UnicodeSet,
    attributes.NumberSetAttribute: custom_fields.NumberSet
}

Then to get past the second issue I passed in any other args or kwargs to the parent constructor for the ModelOpts in schema.py

class ModelOpts(SchemaOpts):
    def __init__(self, meta, *args, **kwargs):
        SchemaOpts.__init__(self, meta, *args, **kwargs)
        self.model = getattr(meta, 'model', None)

After doing that I was able to do basic round trip serialization with simple objects

@fernandochimi-noverde
Copy link

Hello people.

I have the same problem.
Can you have some solution for this issue?

@chrismaille
Copy link

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

4 participants