-
Notifications
You must be signed in to change notification settings - Fork 254
Closed
Description
from datetime import datetime
from pony.orm import *
db = Database()
class Comment(db.Entity):
id = PrimaryKey(int, auto=True)
parent = Optional('Comment')
date = Required(datetime, default=datetime.utcnow)
text = Required(LongStr)
answers = Set('Comment')
composite_index(id, date) # comment it and all will work
db.bind('sqlite', ':memory:')
db.generate_mapping(create_tables=True)
sql_debug(True)
with db_session:
Comment(text='foo')pony.orm.core.CommitException: Object Comment[new:1] cannot be stored in the database. OperationalError: foreign key mismatch - "Comment" referencing "Comment"
Without composite_index field id is "id" INTEGER PRIMARY KEY AUTOINCREMENT. With composite_index – "id" INTEGER NOT NULL.
I don't know, maybe id with composite_index is stupid, but pony should be something to do with it :)
Reactions are currently unavailable