Skip to content

Commit

Permalink
Shuffles class order to group NestedMutable types.
Browse files Browse the repository at this point in the history
  • Loading branch information
edelooff committed Aug 20, 2023
1 parent 3a9f3c4 commit a8709c3
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions sqlalchemy_json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ def __getstate__(self):
return d


class MutableContainer(Mutable):
"""SQLAlchemy `mutable` extension with single-level change tracking list or dict."""

@classmethod
def coerce(cls, key, value):
if value is None:
return value
if isinstance(value, cls):
return value
if isinstance(value, dict):
return MutableDict.coerce(key, value)
if isinstance(value, list):
return MutableList.coerce(key, value)
return super(cls).coerce(key, value)


class NestedMutableDict(TrackedDict, Mutable, _PickleMixin):
@classmethod
def coerce(cls, key, value):
Expand Down Expand Up @@ -51,22 +67,6 @@ def coerce(cls, key, value):
return super(cls).coerce(key, value)


class MutableContainer(Mutable):
"""SQLAlchemy `mutable` extension with single-level change tracking list or dict."""

@classmethod
def coerce(cls, key, value):
if value is None:
return value
if isinstance(value, cls):
return value
if isinstance(value, dict):
return MutableDict.coerce(key, value)
if isinstance(value, list):
return MutableList.coerce(key, value)
return super(cls).coerce(key, value)


def mutable_json_type(dbtype=JSON, nested=False):
"""Type creator for (optionally nested) mutable JSON column types.
Expand Down

0 comments on commit a8709c3

Please sign in to comment.