title: sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.dict' is not mapped
body: <p>I'm trying to insert a new User into a DB using SQLAlchemy and Marshmallow. The <code>user</code> parameter is received from an API endpoint. Everything works until I get to this line in the <code>create</code> function:</p>
  
  <pre><code>db.session.add(new_user)
  </code></pre>
  
  <p>The value of the <code>new_user</code> variable at that point is:</p>
  
  <pre><code>{'password': 'string', 'email': 'fave@string', 'username': 'string'}
  </code></pre>
  
  <p>Function:</p>
  
  <pre><code>def create(user):
      uname = user.get('username')
      email = user.get('email')
      password = user.get ('password')
  
      existing_username = User.query.filter(User.username == uname).one_or_none()
  
      if existing_username is None:
  
          schema = UserSchema()
          new_user = schema.load(user, session=db.session)
  
          db.session.add(new_user) &lt;- It fails here
          db.session.commit()
  
          return schema.dump(new_user), 201
  </code></pre>
  
  <p>Models:</p>
  
  <pre><code>    class User (db.Model):
          id = db.Column(db.Integer, primary_key=True)
          username = db.Column(db.String(20), unique=True, nullable=False)
          email = db.Column(db.String(120), unique=True, nullable=False)
          profile_picture = db.Column(db.String(20), nullable=False, default='default.jpg')
          password = db.Column(db.String(60), nullable=False)
          creation_date = db.Column(db.DateTime(120), nullable=False, default=datetime.utcnow)
          updated_date = db.Column(db.DateTime(120), nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
          posts = db.relationship('Post', backref='author', lazy=True)
  
          def __repr__(self):
              return f"User ('{self.username}','{self.email}','{self.profile_picture}') "
  </code></pre>
  
  <pre><code>    class Post (db.Model):
          id = db.Column(db.Integer, primary_key=True)
          title = db.Column(db.String(100), nullable=False)
          date_posted = db.Column(db.DateTime(120), nullable=False, default=datetime.utcnow)
          content = db.Column(db.Text, nullable=False)
          user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
  
          def __repr__(self):
              return f"Post ('{self.title}','{self.date_posted}') "
  </code></pre>
  
  <p>Schema:</p>
  
  <pre><code>class UserSchema(ma.SQLAlchemyAutoSchema):
      class Meta:
          model = User
          sqla_session = db.session
  </code></pre>
  
  <p>Part of the console errors that I think are relevant:</p>
  
  <pre><code>127.0.0.1 - - [14/May/2020 21:33:35] "POST /api/v1/users HTTP/1.1" 500 -
  Traceback (most recent call last):
    File "/Users/user/.local/share/virtualenvs/apis-JEynsq5i-/Users/user/.pyenv/shims/python/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1975, in add
      state = attributes.instance_state(instance)
  AttributeError: 'dict' object has no attribute '_sa_instance_state'
  
  The above exception was the direct cause of the following exception:
  .
  .
  .
  File "/Users/user/.local/share/virtualenvs/apis-JEynsq5i-/Users/user/.pyenv/shims/python/lib/python3.6/site-packages/connexion/decorators/parameter.py", line 121, in wrapper
      return function(**kwargs)
    File "/Users/user/development/flask/apis/src/users.py", line 100, in create
      db.session.add(new_user)
    File "/Users/user/.local/share/virtualenvs/apis-JEynsq5i-/Users/user/.pyenv/shims/python/lib/python3.6/site-packages/sqlalchemy/orm/scoping.py", line 162, in do
      return getattr(self.registry(), name)(*args, **kwargs)
    File "/Users/user/.local/share/virtualenvs/apis-JEynsq5i-/Users/user/.pyenv/shims/python/lib/python3.6/site-packages/sqlalchemy/orm/session.py", line 1978, in add
      exc.UnmappedInstanceError(instance), replace_context=err,
    File "/Users/user/.local/share/virtualenvs/apis-JEynsq5i-/Users/user/.pyenv/shims/python/lib/python3.6/site-packages/sqlalchemy/util/compat.py", line 178, in raise_
      raise exception
  sqlalchemy.orm.exc.UnmappedInstanceError: Class 'builtins.dict' is not mapped
  </code></pre>
  
  <p>I'm not sure why is throwing that <code>Class 'builtins.dict' is not mapped</code> error. Any tips?</p>