Created on 2021-03-01 16:14 by rouilj, last changed 2021-03-01 16:14 by rouilj.
|msg7083||Author: [hidden] (rouilj)||Date: 2021-03-01 16:14|
In https://sourceforge.net/p/roundup/mailman/message/37225443/ Nagy Gabor asked: Is it possible to tell Roundup to enforce the uniqueness of more than one property of a class? Implement this adding a "unique=BOOLEAN" argument to __init__ of the _Type class in roundup/hyperdb.py. In rdbms backends it should add a unique constraint to the column. In non-rdbms (anydb or other) it will need to execute code to force constraint to be unique. Does this make sense for all types? String (original use case) - yes, "foreign key" to another database somewhere, unique alternate name... Date - maybe, how useful is a unique date? Checking that a date+interval doesn't overlap any other date+interval is more useful (e.g. 1 patient for the 2021-10-14 09:00-09:15 timeperiod). Could be useful is only a date (no time) is used. Link(_Pointer) - maybe, enforce unique relation (e.g. a chassis uses only one inventory number, a second chassis can't claim the same part). Allow only one issue in a particular state. E.G. Only one issue/workorder can be in the paint shop "state" at a time. MultiLink(_Pointer)- maybe, don't have a use case. Number - yes, unique order if you want to include real values. Integer - yes, require unique order value for items Password - no, even the same password will have different salts so every duplicate password will hash as a different value. Interval - no, I think this is useful only with a start date (see discussion on Date above). Boolean - no, only two values so how useful is this Computed (experimental property not in trunk a this time) - no, points to a function Currently this can be implemented using an auditor. See the mailing list discussion for details.