edelooff / sqlalchemy-json

Full-featured JSON type with mutation tracking for SQLAlchemy
http://variable-scope.com/posts/mutation-tracking-in-nested-json-structures-using-sqlalchemy
BSD 2-Clause "Simplified" License
189 stars 34 forks source link

feat: support list in non-nested mutable json #51

Closed iloveitaly closed 1 year ago

edelooff commented 1 year ago

This makes very explicit what essentially was an unintended (but perhaps fine) behavior that's currently in the library: the top-level isn't always a dict.

That was (is?) the basic assumption, but the way NestedMutable is implemented (to support easy nesting), the top-level for that one was allowed to be a list rather than a dict, creating a weird difference between the nested mutable and 'flat mutable'.

The databases seem to be fine with JSON arrays as the top level, so I'm not sure this library should arbitrarily stick to just objects. And even RFC 4627 supports both arrays and objects at the top level, so this seems in line with that and should be supported.

iloveitaly commented 1 year ago

creating a weird difference between the nested mutable and 'flat mutable'.

yeah, this is what was unintuitive to me and the driver behind the change here.

Let me know if any other changes are needed!