Unable to update some Entity in python 3.4 #121

victorien88 opened this Issue Mar 29, 2015 · 7 comments


None yet

4 participants


I migrated one of my project to python 3.4 and since then I'm unable to modify some of my Entities. Eachtime I get :
Traceback (most recent call last):
File "/home/ingest/Mam_Manager_rewrite/modules/models.py", line 1098, in setData
cell.name = value
File "", line 2, in set
File "/usr/local/lib/python3.4/site-packages/pony/utils.py", line 88, in cut_traceback
return func(_args, *_kwargs)
File "/usr/local/lib/python3.4/site-packages/pony/orm/core.py", line 1449, in set
cache.update_composite_index(obj, attrs, prev_vals, new_vals, undo)
File "/usr/local/lib/python3.4/site-packages/pony/orm/core.py", line 1099, in update_composite_index
if prev_vals is not None: del cache_index[prev_vals]
KeyError: ('JOUR1 - GROWTH PANEL',)

The entity is declared this way 👍
class Collection(db.Entity):
id = PrimaryKey(int,sql_type='BIGINT',auto=True)
name = Required(unicode,unique=True)
comment = Optional(unicode)
child = Set("ProjectGroup")


The traceback says about composite index, but I don't see any composite index inside the entity definition. Did entity have any composite index?


Nop the strange is I have no composite index. I never used it.

@kozlovsky kozlovsky added the bug label Mar 29, 2015
@kozlovsky kozlovsky added this to the 0.6.2 milestone Mar 29, 2015
@kozlovsky kozlovsky self-assigned this Mar 29, 2015

Thanks for the reporting, I was able to reproduce the bug. Will investigate into it.

@kozlovsky kozlovsky closed this in bff4e68 Mar 30, 2015

Fixed. The bug was introduced in release 0.6.1. The fix will be part of the new release 0.6.2. Right now you can take the latest PonyORM version from the GitHub or roll back to release 0.6


also example of program that reproduce that bug:

from pony.orm import db_session, Database, Required
database = Database()
class Tbl(database.Entity):
    f1 = Required(str, unique=True)
database.bind('sqlite', ':memory:', create_db=True)
with db_session:
    xxx = Tbl(f1='tmp_peer_config')
    xxx.f1 = 'asd'

I cannot rollback to 6.0 since it have another annoying bug: when .exists return True on empty database. (Cannot find that issue on github)


@socketpair did you mean that the bug is not fixed yet? The latest repository code behave well in my testing. Or you mean that you are awaiting official release with this bug fixed?

exists bug was not reported on the GitHub, it was fixed in commit 17db84e

@kozlovsky kozlovsky added a commit that referenced this issue Jan 11, 2016
@kozlovsky kozlovsky Pony ORM Release 0.6.2 (2015-01-11)
The documentation was moved from this repo to a separate one at https://github.com/ponyorm/pony-doc
The compiled version can be found at https://docs.ponyorm.com

# New features

* Python 3.5 support
* #132, #145: raw_sql() function was added
* #126: Ability to use @db_session with generator functions
* #116: Add support to select by UUID
* Ability to get string SQL statement using the Query.get_sql() method
* New function delete(gen) and Query.delete(bulk=False)
* Now it is possible to override Entity.__init__() and declare custom entity methods

# Backward incompatible changes

* Normalizing table names for symmetric relationships
* Autostrip - automatically remove leading and trailing characters

# Bugfixes

* #87: Pony fails with pymysql installed as MySQLdb
* #118: Pony should reconnect if previous connection was created before process was forked
* #121: Unable to update value of unique attribute
* #122: AssertionError when changing part of a composite key
* #127: a workaround for incorrect pysqlite locking behavior
* #136: Cascade delete does not work correctly for one-to-one relationships
* #141, #143: remove restriction on adding new methods to entities
* #142: Entity.select_random() AssertionError
* #147: Add 'atom_expr' symbol handling for Python 3.5 grammar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment