File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1648,6 +1648,8 @@ def __init__(self, *path):
16481648 self ._path = [p for p in path if p ]
16491649
16501650 def __getattr__ (self , attr ):
1651+ if attr .startswith ('__' ) and attr .endswith ('__' ):
1652+ return super (Entity , self ).__getattr__ (attr )
16511653 return Entity (* self ._path + [attr ])
16521654
16531655 def get_sort_key (self , ctx ):
Original file line number Diff line number Diff line change @@ -912,6 +912,21 @@ class SmInt(Base):
912912 '"value" INTEGER NOT NULL, '
913913 '"label" VARCHAR(255) NOT NULL)' ), [])
914914
915+ def test_constraint_inheritance (self ):
916+ class Product (TestModel ):
917+ price = IntegerField (constraints = [Check ('price > 0' , name = 'pc' )])
918+ class Child (Product ):
919+ pass
920+
921+ self .assertSQL (Product ._schema ._create_table (False ), (
922+ 'CREATE TABLE "product" ('
923+ '"id" INTEGER NOT NULL PRIMARY KEY, '
924+ '"price" INTEGER NOT NULL CONSTRAINT "pc" CHECK (price > 0))' ), [])
925+ self .assertSQL (Child ._schema ._create_table (False ), (
926+ 'CREATE TABLE "child" ('
927+ '"id" INTEGER NOT NULL PRIMARY KEY, '
928+ '"price" INTEGER NOT NULL CONSTRAINT "pc" CHECK (price > 0))' ), [])
929+
915930
916931class TestDDLAdditionalSQL (ModelDatabaseTestCase ):
917932 database = get_in_memory_db ()
You can’t perform that action at this time.
0 commit comments