Skip to content

refactor!: uncouple fields from hard-coded values#1354

Open
CyanVoxel wants to merge 6 commits intomainfrom
fields-refactor
Open

refactor!: uncouple fields from hard-coded values#1354
CyanVoxel wants to merge 6 commits intomainfrom
fields-refactor

Conversation

@CyanVoxel
Copy link
Copy Markdown
Member

@CyanVoxel CyanVoxel commented May 8, 2026

Warning

This PR bumps the major version of the library database to 200. Please backup any existing libraries before testing.

Summary

This PR uncouples fields from hard-coded values such as enums and immutable SQLite tables, allowing for the foundation of independently customizable field names and user field templates (intended for a future PR).

Legacy "TEXT_LINE" and "TEXT_BOX" field types are now a single TextField type, distinguished by an is_multiline boolean attribute. This allows for a future UI change where all text fields can be edited in a single modal that adapts to the attributes present and allows for any text attributes to be changed for the field.

I've also reduced the set of default field "templates", in preparation for a future PR that allows for the creation of user created field templates. Unlike the built-in tags, these fields are merely a jumping-off point for users to customize or remove as they see fit.
image

These changes also open the door for additional field type attributes, for example is_rich_text or is_hyperlink for TextFields or is_time for DatetimeFields.

NOTE: I was unable to remove the now-unused type_key columns from the text_fields and datetime_fields tables for existing libraries due to them containing foreign key relationships. This is not an urgent issue, but is something that should be addressed in the future. See this issue with dropping columns foreign keys in SQLite: https://www.sqlite.org/lang_altertable.html#making_other_kinds_of_table_schema_changes

Tasks Completed

  • Platforms Tested:
    • Windows x86
    • Windows ARM
    • macOS x86
    • macOS ARM
    • Linux x86
    • Linux ARM
  • Tested For:
    • Basic functionality
    • PyInstaller executable

@CyanVoxel CyanVoxel added this to the Alpha v9.6.0 milestone May 8, 2026
@CyanVoxel CyanVoxel added Type: Refactor Code that needs to be restructured or cleaned up TagStudio: Library Relating to the TagStudio library system Priority: Medium An issue that shouldn't be be saved for last Status: Review Needed A review of this is needed labels May 8, 2026
@CyanVoxel CyanVoxel moved this to 🏓 Ready for Review in TagStudio Development May 8, 2026
@CyanVoxel CyanVoxel moved this from 🏓 Ready for Review to 🚧 In progress in TagStudio Development May 9, 2026
@CyanVoxel CyanVoxel marked this pull request as draft May 9, 2026 02:37
@CyanVoxel CyanVoxel marked this pull request as ready for review May 9, 2026 03:45
Copy link
Copy Markdown
Collaborator

@Computerdores Computerdores left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

welp that was a huge PR ^^
didn't test it locally and probably won't have time to do so either

Comment thread src/tagstudio/core/library/alchemy/library.py Outdated
Comment thread src/tagstudio/core/library/alchemy/library.py
Comment thread src/tagstudio/core/library/alchemy/library.py
Comment thread src/tagstudio/core/library/alchemy/library.py Outdated
Comment thread src/tagstudio/core/library/alchemy/library.py Outdated
Comment thread src/tagstudio/qt/mixed/field_containers.py Outdated
Comment thread src/tagstudio/qt/mixed/field_containers.py
Comment on lines +74 to +76
"field_type.datetime": "Datetime",
"field_type.text": "Text",
"field_type.unknown": "Unknown Type",
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want you can throw this into the german translation:

    "field_type.datetime": "Datum - Uhrzeit",
    "field_type.text": "Text",
    "field_type.unknown": "Unbekannter Typ",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll wait to do that on the Weblate side afterwards 👍

Comment thread tests/macros/test_dupe_files.py Outdated
Comment thread tests/test_library.py Outdated
@Computerdores Computerdores moved this from 🚧 In progress to 👀 In review in TagStudio Development May 9, 2026
@Computerdores Computerdores removed the Status: Review Needed A review of this is needed label May 9, 2026
@Computerdores
Copy link
Copy Markdown
Collaborator

I think this conflicts with #1198 btw

Comment thread src/tagstudio/core/library/alchemy/library.py Outdated
Comment thread src/tagstudio/qt/mixed/field_containers.py Outdated
Comment thread src/tagstudio/qt/mixed/field_containers.py Outdated
Comment thread src/tagstudio/core/library/alchemy/library.py
Comment thread src/tagstudio/core/library/alchemy/library.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Priority: Medium An issue that shouldn't be be saved for last TagStudio: Library Relating to the TagStudio library system Type: Refactor Code that needs to be restructured or cleaned up

Projects

Status: 👀 In review

Development

Successfully merging this pull request may close these issues.

2 participants