Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problems with WITHOUT ROWID tables with PK of string type (sqlitebrow…
…ser#1559) * Problems with WITHOUT ROWID tables with PK of string type This fixes two related problems: - When the PK is updated the hidden column 0 must be updated too, otherwise any further editing of the same row before a table refresh is broken. - When a new record is inserted and the PK has string type we cannot simply make a pseudo auto-increment and insert that value as rowid because that added key would be impossible to update because our UPDATE clause will try to update a column with a string and it contains an integer. In this case it's better to let the user enter the PK value, so the new Add Record dialog is directly invoked. See issue sqlitebrowser#1332 and (tangentially) sqlitebrowser#1049. The first should be fixed now. The later not, but at least there is now a workaround: removing the AUTOINCREMENT option and use the WITHOUT ROWID one. * Problems with WITHOUT ROWID tables with PK of string type (alternative 2) Update after review: - cached_row is not modified after unlock(); - Alternative solution to initial key value insertion: When a new record is inserted and the PK has string type we still make a pseudo auto-increment and insert that value as a string literal. In this way we can later update that row. When we inserted it as integer an actual integer will be inserted by SQLite, and our UPDATE clause, which always uses string in the WHERE condition, won't match the row (SQLite does not convert to integer when the column is of type string in this context). See issue sqlitebrowser#1332.
- Loading branch information