@@ -193,6 +193,7 @@
Loading
193 193
                 supports_dict = False,
194 194
                 on_serialize = None,
195 195
                 on_deserialize = None,
196 +
                 display_name = None,
196 197
                 **kwargs):
197 198
        """Provide a relationship between two mapped classes.
198 199
@@ -353,6 +354,7 @@
Loading
353 354
        self.supports_dict = supports_dict
354 355
        self.on_serialize = on_serialize
355 356
        self.on_deserialize = on_deserialize
357 +
        self.display_name = display_name
356 358
357 359
        comparator_factory = kwargs.pop('comparator_factory', RelationshipProperty.Comparator)
358 360
@@ -388,7 +390,11 @@
Loading
388 390
389 391
        @property
390 392
        def on_deserialize(self):
391 -
            return self.prop.on_deserialize
393 +
            return self.prop.on_deserialize\
394 +
395 +
        @property
396 +
        def display_name(self):
397 +
            return self.prop.display_name
392 398
393 399
394 400
relationship = public_factory(RelationshipProperty, ".orm.relationship")

@@ -6,7 +6,9 @@
Loading
6 6
# there as needed.
7 7
8 8
import inspect as inspect_
9 +
import yaml
9 10
11 +
from sqlathanor._compat import json
10 12
from sqlathanor.attributes import validate_serialization_config
11 13
from sqlathanor.utilities import format_to_tuple
12 14
from sqlathanor.default_serializers import get_default_serializer
@@ -261,10 +263,19 @@
Loading
261 263
                resolved_class = None
262 264
            if resolved_class:
263 265
                # pylint: disable=W0212
264 -
                return_value = [resolved_class(
265 -
                    **resolved_class._parse_dict(x,
266 -
                                                 format,
267 -
                                                 **kwargs)) for x in value]
266 +
                if hasattr(resolved_class, 'new_from_json') and format == 'json' and isinstance(value, dict):
267 +
                    as_json = json.dumps(value)
268 +
                    return_value = resolved_class.new_from_json(as_json, **kwargs)
269 +
                elif hasattr(resolved_class, 'new_from_yaml') and format == 'yaml' and isinstance(value, dict):
270 +
                    as_yaml = yaml.dump(value)
271 +
                    return_value = resolved_class.new_from_yaml(value, **kwargs)
272 +
                elif hasattr(resolved_class, 'new_from_dict') and format == 'dict' and isinstance(value, dict):
273 +
                    return_value = resolved_class.new_from_dict(value, **kwargs)
274 +
                else:
275 +
                    return_value = [resolved_class(
276 +
                        **resolved_class._parse_dict(x,
277 +
                                                     format,
278 +
                                                     **kwargs)) for x in value]
268 279
                #pylint: enable=W0212
269 280
            else:
270 281
                return_value = value

@@ -437,8 +437,6 @@
Loading
437 437
        raise DeserializationError('input_data is not a valid string')
438 438
439 439
    if not is_file:
440 -
        print(type(input_data))
441 -
        print(input_data)
442 440
        from_yaml = yaml.safe_load(input_data, **kwargs)
443 441
    else:
444 442
        with open(input_data, 'r') as input_file:
Files Coverage
sqlathanor 78.26%
Project Totals (20 files) 78.26%
152.22
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy12-pyyaml42b2-simplejson316
152.26
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson33
152.27
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson34
152.25
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson32
152.21
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy12-pyyaml42b1-simplejson316
152.18
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml42b2-simplejson316
152.23
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson30
152.24
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson31
152.28
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson35
152.29
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
TOXENV=.python37-sqlalchemy10-pyyaml313-simplejson36
151.150
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=coverage
coverage=
151.150
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
TOXENV=coverage
152.2
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson31
152.1
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson30
152.4
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson33
152.3
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson32
152.7
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson36
152.5
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson34
152.9
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson38
152.8
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
TOXENV=.python38-sqlalchemy10-pyyaml313-simplejson37