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

AssertionError #238

p-hash opened this issue Feb 21, 2017 · 2 comments

AssertionError #238

p-hash opened this issue Feb 21, 2017 · 2 comments


Copy link

p-hash commented Feb 21, 2017

I am migrating lots of data from mongodb to postgresql using ponyorm in custom migration script.
After some work it fails with this error:

Traceback (most recent call last):
  File "", line 252, in <module>
    migrate_botdata(bot_db.common, newbot)
  File "", line 226, in migrate_botdata
  File "<string>", line 2, in __init__
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/utils/", line 58, in cut_traceback
    return func(*args, **kwargs)
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 4199, in __init__
    entity._get_from_identity_map_(pkval, 'created', undo_funcs=undo_funcs, obj_to_init=obj)
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 3992, in _get_from_identity_map_
    if attr.reverse: attr.update_reverse(obj, NOT_LOADED, val, undo_funcs)
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 2131, in update_reverse
    if new_val is not None: reverse.__set__(new_val, obj, undo_funcs)
  File "<string>", line 2, in __set__                                                                                                                                       File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/utils/", line 58, in cut_traceback
    return func(*args, **kwargs)                                                                                                                                            File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 2000, in __set__                                                                 old_val = attr.load(obj)
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 1936, in load
    dbval = reverse.entity._find_in_db_({reverse : obj})
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 3730, in _find_in_db_
    objects = entity._fetch_objects(cursor, attr_offsets, 1, for_update, avdict)
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 3862, in _fetch_objects
  File "/home/paul/tmp/mpb_migration/env/lib/python3.4/site-packages/pony/orm/", line 4367, in _db_set_
    assert obj._status_ not in created_or_deleted_statuses

I understand that there can be duplicates in my old data which can violate constraints in posgresql, but how am i supposed to find them basing on that error?

Copy link

p-hash commented Feb 21, 2017

#133 is about same issue, i guess

@kozlovsky kozlovsky self-assigned this Mar 24, 2017
@kozlovsky kozlovsky added the bug label Mar 24, 2017
@kozlovsky kozlovsky added this to the 0.7.2 milestone Mar 24, 2017
Copy link

kozlovsky commented Mar 24, 2017

Fixed, now you should see a descriptive error message which contains primary key of a duplicate object

kozlovsky added a commit that referenced this issue Jul 17, 2017
# New features

* All arguments of db.bind() can be specified as keyword arguments. Previously Pony required the first positional argument which specified the database provider. Now you can pass all the database parameters using the dict: db.bind(**db_params). See
* The `optimistic` attribute option is added

# Bugfixes

* Fixes #219: when a database driver raises an error, sometimes this error was masked by the 'RollbackException: InterfaceError: connection already closed' exception. This happened because on error, Pony tried to rollback transaction, but the connection to the database was already closed and it masked the initial error. Now Pony displays the original error which helps to understand the cause of the problem.
* Fixes #276: Memory leak
* Fixes the __all__ declaration. Previously IDEs, such as PyCharm, could not understand what is going to be imported by 'from pony.orm import *'. Now it works fine.
* Fixes #232: negate check for numeric expressions now checks if value is zero or NULL
* Fixes #238, fixes #133: raise TransactionIntegrityError exception instead of AssertionError if obj.collection.create(**kwargs) creates a duplicate object
* Fixes #221: issue with unicode json path keys
* Fixes bug when discriminator column is used as a part of a primary key
* Handle situation when SQLite blob column contains non-binary value
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