Hello,
it seems, that the unique-parameter is only taken into during the runtime of the script, but not respecting already written values.
See the following code-snippet, when running the first-time, the database is created and the values are written. When running it the second time, the values are appended, but the user_id-unique-value is not respected, so the user-ids are duplicated without any exception..
Is this a known behaviour?
Thanks,
best regards,
Josef
from tinydb import TinyDB, Query
from tinydb_constraint import ConstraintTable
from tinydb_constraint import Constraint
TinyDB.table_class = ConstraintTable
db = TinyDB('db.json')
db.set_schema({'user_id': Constraint(type_=int, unique=True, not_null=True)})
db.insert({'user_id':1,'par':"val1"})
db.insert({'user_id':2,'par':"val2"})
db.insert({'user_id':3,'par':"val3"})
Hello,
it seems, that the unique-parameter is only taken into during the runtime of the script, but not respecting already written values.
See the following code-snippet, when running the first-time, the database is created and the values are written. When running it the second time, the values are appended, but the user_id-unique-value is not respected, so the user-ids are duplicated without any exception..
Is this a known behaviour?
Thanks,
best regards,
Josef
from tinydb import TinyDB, Queryfrom tinydb_constraint import ConstraintTablefrom tinydb_constraint import ConstraintTinyDB.table_class = ConstraintTabledb = TinyDB('db.json')db.set_schema({'user_id': Constraint(type_=int, unique=True, not_null=True)})db.insert({'user_id':1,'par':"val1"})db.insert({'user_id':2,'par':"val2"})db.insert({'user_id':3,'par':"val3"})