Skip to content Skip to sidebar Skip to footer

Replace Path String In Sqlite Db Causes Unexpected Violated Unique Constraint

I'm not sure whether I've found a bug in SQLite or whether I'm simply not using it correctly. I'm storing relative file paths (as you know them from UNIX file systems) in a DB. For

Solution 1:

INSERTINTO test (path) VALUES ('a/d/a');
INSERTINTO test (path) VALUES ('a/a/a');

After replacing a/ with d/, both values are d/d/a.

If you want to change only an a/ at the start of the string, you cannot use replace():

UPDATE test
SET path = 'd/' || substr(path, 3)
WHERE path GLOB 'a/*';

Post a Comment for "Replace Path String In Sqlite Db Causes Unexpected Violated Unique Constraint"