Skip to content

MariaDB: Incorrect migration truncates descriptions in the index #2398

@benjaminjonard

Description

@benjaminjonard

Hello,

I recently noticed that all descriptions on my photos where deleted (no worries, I got them back from a backup)

But with a bit of testing I could track down the issue to the release of May 17, 2022 and specifically to this migration : https://github.com/photoprism/photoprism/blob/7ba043a559a59663274d9504813cfe5981029010/internal/migrate/mysql/20220329-050000.sql

I'm using MariaDb 10.7, and if I run the following query SELECT SUBSTR(photo_description, 0, 4096) FROM photos; the result is always empty. The consequence is that the first statement in the migration file (UPDATE photos SET photo_description = SUBSTR(photo_description, 0, 4096) WHERE 1;) erases all descriptions.

When looking at MariaDB docs here https://mariadb.com/kb/en/substring/, there is written "By default, the position of the first character in the string from which the substring is to be extracted is reckoned as 1. "
Changing the query to SELECT SUBSTR(photo_description, 1, 4096) FROM photos; is working as intended. But I'm not sure it would suit everyone's configuration.

I also found this article that explains this position problem more clearly.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingreleasedAvailable in the stable release

Type

No type

Projects

Status

Release 🌈

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions