Also maybe useful https://github.com/web2py/pydal/issues/627
пятница, 23 октября 2020 г. в 08:32:16 UTC+3, [email protected]: > Also I fixed some bugs https://github.com/web2py/pydal/issues/548 > > пятница, 23 октября 2020 г. в 08:25:23 UTC+3, [email protected]: > >> >> Shared pk works just fine: >> >> >> db.define_table( >> 'datetime_duration', >> Field('superclass','reference duration') , >> primarykey = ['superclass'] >> ) >> воскресенье, 18 октября 2020 г. в 02:23:00 UTC+3, BigBaaadBob: >> >>> It's hard to believe that I was talking about this in 2013 >>> <https://groups.google.com/g/web2py/c/Vh-J2AQ-mBE/m/xOMh3mm7ovEJ>, but >>> here it is again! >>> >>> I'm wondering if you can directly implement the Table-per-type or >>> Shared-primary-key method of inheritance in the DAL? >>> >>> [image: subclass-gradstu-scheme.gif] >>> >>> The standard DAL inheritance method (including a table as a field) is a >>> Table-per-concrete approach that has pros and cons. In particular for me, >>> it is harder to deal with the common stuff (the stuff in the superclass) >>> with the standard DAL method. In many cases I never need to refer to the >>> subclass specifics. >>> >>> The best I have been able to do is something like the below. There is a >>> lot of common stuff in the duration table (and, btw, the duration can be >>> overridden and isn't necessarily the difference of the start and stop >>> values in the subclasses). Depending on how the time is tracked, there are >>> different algorithms used to compute a duration, for example subtracting >>> two datetimes or subtracting two floats (representing hours). >>> >>> db.define_table( >>> 'duration', >>> # Common stuff >>> Field('duration','decimal(10,2)',notnull=True), >>> ) >>> >>> db.define_table( >>> 'datetime_duration', >>> Field('superclass','reference duration',unique=True,notnull=True), >>> Field('start','datetime',notnull=True), >>> Field('stop','datetime',notnull=True), >>> ) >>> >>> db.define_table( >>> 'hour_duration', >>> Field('superclass','reference duration',unique=True,notnull=True), >>> Field('start','decimal(10,2)',notnull=True), >>> Field('stop','decimal(10,2)',notnull=True), >>> ) >>> >>> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/d560f486-6892-44e6-8101-f9217c3de8f2n%40googlegroups.com.

