File tree 2 files changed +2
-14
lines changed
tagstudio/src/core/library/alchemy 2 files changed +2
-14
lines changed Original file line number Diff line number Diff line change 4
4
from enum import Enum
5
5
from typing import Any , TYPE_CHECKING
6
6
7
- from sqlalchemy import ForeignKey , ForeignKeyConstraint
7
+ from sqlalchemy import ForeignKey
8
8
from sqlalchemy .orm import Mapped , mapped_column , relationship , declared_attr
9
9
10
10
from .db import Base
@@ -39,7 +39,7 @@ def entry(cls) -> Mapped[Entry]:
39
39
40
40
@declared_attr
41
41
def position (cls ) -> Mapped [int ]:
42
- return mapped_column ()
42
+ return mapped_column (default = 0 )
43
43
44
44
def __hash__ (self ):
45
45
return hash (self .__key ())
@@ -66,13 +66,6 @@ def __eq__(self, value) -> bool:
66
66
67
67
class TextField (BaseField ):
68
68
__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
- )
76
69
77
70
value : Mapped [str | None ]
78
71
Original file line number Diff line number Diff line change 2
2
import shutil
3
3
from os import makedirs
4
4
from pathlib import Path
5
- from random import randint
6
5
from typing import Iterator , Any , Type
7
6
from uuid import uuid4
8
7
@@ -632,7 +631,6 @@ def add_entry_field_type(
632
631
field_model = TextField (
633
632
type_key = field .key ,
634
633
value = value or "" ,
635
- position = randint (100 , 100_000 ),
636
634
)
637
635
elif field .type == FieldTypeEnum .TAGS :
638
636
field_model = TagBoxField (
@@ -656,9 +654,6 @@ def add_entry_field_type(
656
654
try :
657
655
for entry_id in entry_ids :
658
656
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
-
662
657
session .add (field_model )
663
658
session .flush ()
664
659
You can’t perform that action at this time.
0 commit comments