1616from sqlalchemy import String , Integer , ForeignKey
1717from sqlalchemy .orm import mapped_column , relationship
1818
19- from db .base import AutoBaseMixin , Base
19+ from db .base import AutoBaseMixin , Base , lexicon_term
2020
2121
2222class Lexicon (Base , AutoBaseMixin ):
@@ -60,9 +60,7 @@ class TermCategoryAssociation(Base, AutoBaseMixin):
6060
6161 __tablename__ = "lexicon_term_category_association"
6262
63- lexicon_term = mapped_column (
64- String (100 ), ForeignKey ("lexicon_term.term" , ondelete = "CASCADE" ), nullable = False
65- )
63+ lexicon_term = lexicon_term (foreignkeykw = {"ondelete" : "CASCADE" })
6664 category_name = mapped_column (
6765 String (255 ),
6866 ForeignKey ("lexicon_category.name" , ondelete = "CASCADE" ),
@@ -82,13 +80,9 @@ class LexiconTriple(Base, AutoBaseMixin):
8280 This can be used to represent relationships between terms.
8381 """
8482
85- subject = mapped_column (
86- String (100 ), ForeignKey ("lexicon_term.term" , ondelete = "CASCADE" ), nullable = False
87- )
83+ subject = lexicon_term (nullable = False )
8884 predicate = mapped_column (String (100 ), nullable = False )
89- object_ = mapped_column (
90- String (100 ), ForeignKey ("lexicon_term.term" , ondelete = "CASCADE" ), nullable = False
91- )
85+ object_ = lexicon_term (nullable = False )
9286
9387 subject_term = relationship ("Lexicon" , foreign_keys = [subject ])
9488 object_term = relationship ("Lexicon" , foreign_keys = [object_ ])
0 commit comments