Skip to content

Commit

Permalink
better casting for operation
Browse files Browse the repository at this point in the history
  • Loading branch information
joamag committed Oct 23, 2015
1 parent e86a30c commit 69d18b4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/quorum/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def singleton(

@classmethod
def get(cls, *args, **kwargs):
fields, eager, map, rules, meta, fill, build, skip, limit, sort, raise_e = cls._get_attrs(kwargs, (
fields, eager, map, rules, meta, build, fill, skip, limit, sort, raise_e = cls._get_attrs(kwargs, (
("fields", None),
("eager", None),
("map", False),
Expand Down Expand Up @@ -1888,7 +1888,11 @@ def cast(self, values):
parameters = self.get("parameters", [])
for value, parameters in zip(values, parameters):
cast = parameters[2]
if cast and not value in (None, ""): value = cast(value)
is_default = value in (None, "")
if cast in ("file",): cast = None
if cast in ("longtext",): cast = legacy.UNICODE
if cast and not is_default: value = cast(value)
if is_default: value = TYPE_DEFAULTS.get(cast, value)
casted.append(value)

# returns the final list of casted values to the caller method
Expand Down

0 comments on commit 69d18b4

Please sign in to comment.