You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Postgresql database generates a valid table schema:
CREATE TABLE flight
(
id serial NOT NULL,
category text NOT NULL,
aircraft integer NOT NULL,
travel_date date NOT NULL,
pilot character varying(255) NOT NULL,
notes text NOT NULL,
status text NOT NULL,
CONSTRAINT flight_pkey PRIMARY KEY (id),
CONSTRAINT fk_flight__aircraft FOREIGN KEY (aircraft)
REFERENCES aircraft (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE NO ACTION
)
WITH (
OIDS=FALSE
);
ALTER TABLE flight
OWNER TO maw;
-- Index: idx_flight__aircraft
-- DROP INDEX idx_flight__aircraft;
CREATE INDEX idx_flight__aircraft
ON flight
USING btree
(aircraft);
File "<auto generated wrapper of commit() function>", line 2, in commit
File "venv\lib\site-packages\pony\utils.py", line 65, in cut_traceback
return func(*args, **kwargs)
File "venv\lib\site-packages\pony\orm\core.py", line 596, in commit
if cache is not None: cache.commit()
File "venv\lib\site-packages\pony\orm\core.py", line 1518, in commit
if cache.modified: cache.flush()
File "venv\lib\site-packages\pony\orm\core.py", line 1583, in flush
if obj is not None: obj._save_()
File "venv\lib\site-packages\pony\orm\core.py", line 4734, in _save_
else: assert False, "_save_() called for object %r with incorrect status %s" % (obj, status) # pragma: no cover
AssertionError: _save_() called for object Flight[1] with incorrect status inserted
If I remove the assignment of booking to flight everything works ok. I inspected the variable stack using PyCharm's debugger and indeed the status is "inserted" for the Flight object:
I can confirm that the problem is fixed for me when patching core with this commit.
Thanks!
kozlovsky
changed the title
AssertionError: _save_() called for object with incorrect status inserted
AssertionError when saving changes of multiple objects
Apr 4, 2016
# Improvements
* Fixes#172: Query prefetch() method should load specified lazy attributes right in the main query if possible
# Bugfixes
* Fixes#168: Incorrect caching when slicing the same query multiple times
* Fixes#169: When py_check() returns False, Pony should truncate too large values in resulting ValueError message
* Fixes#171: AssertionError when saving changes of multiple objects
* Fixes#176: Autostripped strings are not validated correctly for Required attributes
See blog post for more detailed information: https://blog.ponyorm.com/2016/04/04/pony-orm-release-0-6-5/
Given the following models:
The Postgresql database generates a valid table schema:
When I insert a booking and a flight like this:
I get the following error
If I remove the assignment of booking to flight everything works ok. I inspected the variable stack using PyCharm's debugger and indeed the status is "inserted" for the Flight object:
The text was updated successfully, but these errors were encountered: