Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get json attribute from Set #315

xunto opened this issue Nov 22, 2017 · 4 comments

Can't get json attribute from Set #315

xunto opened this issue Nov 22, 2017 · 4 comments


Copy link

xunto commented Nov 22, 2017

I have a model like this:

class Pool(db.Entity):
    pool_name = Required(str, unique=True)

    builds = Set(lambda: Build)

class Build(db.Entity):
    data = Required(Json)

    pools = Set(lambda: Pool)

but when I do something like:

I get:

    def distinct(iter):
        d = defaultdict(int)
        for item in iter:
>           d[item] = d[item] + 1
E           TypeError: unhashable type: 'TrackedDict'

Tested on master branch(orm)

Copy link

kozlovsky commented Nov 22, 2017

Hi Valentine, what result are you expecting to get?

Copy link

xunto commented Nov 22, 2017

@kozlovsky Hi! I expect to get set or list of json's. It works that way with most of types.

Copy link

We cannot return a set of json's, because json value is subclass of dict and cannot be item of set. Probably for such attributes we can indeed return a list of dicts. I think the result elements should be not a TrackedDict instances, but just plain dicts, and their subsequent modifications should not be reflected in models.

@kozlovsky kozlovsky self-assigned this Nov 22, 2017
@kozlovsky kozlovsky added the bug label Nov 22, 2017
Copy link

xunto commented Nov 22, 2017

@kozlovsky yeah, sounds good. I forgot that you can't store dicts in set (even though I felt that something is wrong about it).

@kozlovsky kozlovsky added this to the 0.7.4 milestone Nov 26, 2017
kozlovsky added a commit that referenced this issue Jul 23, 2018
# Major features

* Hybrid methods and properties added:
* Allow to base queries on another queries: `select(x.a for x in prev_query if x.b)`
* Added support of Python 3.7
* Added support of PyPy
* `group_concat()` aggregate function added
* pony.flask subpackage added for integration with Flask

# Other features

* `distinct` option added to aggregate functions
* Support of explicit casting to `float` and `bool` in queries

# Improvements

* Apply @cut_traceback decorator only when pony.MODE is 'INTERACTIVE'

# Bugfixes

* In SQLite3 `LIKE` is case sensitive now
* #249: Fix incorrect mixin used for Timedelta
* #251: correct dealing with qualified table names
* #301: Fix aggregation over JSON Column
* #306: Support of frozenset constants added
* #308: Fixed an error when assigning JSON attribute value to the same attribute: obj.json_attr = obj.json_attr
* #313: Fix missed retry on exception raised during db_session.__exit__
* #314: Fix AttributeError: 'NoneType' object has no attribute 'seeds'
* #315: Fix attribute lifting for JSON attributes
* #321: Fix KeyError on obj.delete()
* #325: duplicating percentage sign in raw SQL queries without parameters
* #331: Overriding __len__ in entity fails
* #336: entity declaration serialization
* #357: reconnect after PostgreSQL server closed the connection unexpectedly
* Fix Python implementation of between() function and rename arguments: between(a, x, y) -> between(x, a, b)
* Fix retry handling: in PostgreSQL and Oracle an error can be raised during commit
* Fix optimistic update checks for composite foreign keys
* Don't raise OptimisticCheckError if db_session is not optimistic
* Handling incorrect datetime values in MySQL
* Improved ImportError exception messages when MySQLdb, pymysql, psycopg2 or psycopg2cffi driver was not found
* desc() function fixed to allow reverse its effect by calling desc(desc(x))
* __contains__ method should check if objects belong to the same db_session
* Fix pony.MODE detection; mod_wsgi detection according to official doc
* A lot of inner fixes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

2 participants