File tree Expand file tree Collapse file tree 2 files changed +2
-14
lines changed
tagstudio/src/core/library/alchemy Expand file tree Collapse file tree 2 files changed +2
-14
lines changed Original file line number Diff line number Diff line change 44from enum import Enum
55from typing import Any , TYPE_CHECKING
66
7- from sqlalchemy import ForeignKey , ForeignKeyConstraint
7+ from sqlalchemy import ForeignKey
88from sqlalchemy .orm import Mapped , mapped_column , relationship , declared_attr
99
1010from .db import Base
@@ -39,7 +39,7 @@ def entry(cls) -> Mapped[Entry]:
3939
4040 @declared_attr
4141 def position (cls ) -> Mapped [int ]:
42- return mapped_column ()
42+ return mapped_column (default = 0 )
4343
4444 def __hash__ (self ):
4545 return hash (self .__key ())
@@ -66,13 +66,6 @@ def __eq__(self, value) -> bool:
6666
6767class TextField (BaseField ):
6868 __tablename__ = "text_fields"
69- # constrain for combination of: entry_id, type_key and position
70- __table_args__ = (
71- ForeignKeyConstraint (
72- ["entry_id" , "type_key" , "position" ],
73- ["text_fields.entry_id" , "text_fields.type_key" , "text_fields.position" ],
74- ),
75- )
7669
7770 value : Mapped [str | None ]
7871
Original file line number Diff line number Diff line change 22import shutil
33from os import makedirs
44from pathlib import Path
5- from random import randint
65from typing import Iterator , Any , Type
76from uuid import uuid4
87
@@ -632,7 +631,6 @@ def add_entry_field_type(
632631 field_model = TextField (
633632 type_key = field .key ,
634633 value = value or "" ,
635- position = randint (100 , 100_000 ),
636634 )
637635 elif field .type == FieldTypeEnum .TAGS :
638636 field_model = TagBoxField (
@@ -656,9 +654,6 @@ def add_entry_field_type(
656654 try :
657655 for entry_id in entry_ids :
658656 field_model .entry_id = entry_id
659- # create random value position to avoid IntegrityError, reordering is below
660- field_model .position = randint (100 , 100_000 )
661-
662657 session .add (field_model )
663658 session .flush ()
664659
You can’t perform that action at this time.
0 commit comments