From b1fcdf94e92adfb5177f0f1bc0a2444bfbefc562 Mon Sep 17 00:00:00 2001 From: Kazantcev Andrey <45011689+heckad@users.noreply.github.com> Date: Mon, 17 Jun 2019 00:15:28 +0300 Subject: [PATCH] Fix https://github.com/marshmallow-code/flask-marshmallow/issues/44 --- src/marshmallow_sqlalchemy/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/marshmallow_sqlalchemy/schema.py b/src/marshmallow_sqlalchemy/schema.py index f347da00..a4ff5246 100644 --- a/src/marshmallow_sqlalchemy/schema.py +++ b/src/marshmallow_sqlalchemy/schema.py @@ -173,7 +173,7 @@ def get_instance(self, data): :param data: Serialized data to inform lookup. """ - if self.transient: + if self.transient or not hasattr(self.session, 'query'): return None props = get_primary_keys(self.opts.model) filters = {prop.key: data.get(prop.key) for prop in props}