Skip to content

[Bug]: Primary key rename leads to unwanted schema change #4163

Open

Description

@VxTedxV

What did you do?

When renaming a non-editable default "pkuid" primary key name from a table generated from QGis with this kind of table schema :
CREATE TABLE "table_name" (pkuid integer primary key autoincrement, ....)
DB Browser for SQLite alters it to
CREATE TABLE "table_name" ("new_key_name" integer, .... , PRIMARY KEY ("new_key_name" AUTOINCREMENT) )
All seems to work until creating entities in QGis when primary key autoincrementing doesn't work anymore.
See qgis/QGIS#22330

What did you expect to see?

I expect that DB Browser for SQLite respects initial schema :
CREATE TABLE "table_name" ("new_key_name" integer primary key autoincrement, ....)

What did you see instead?

Instead it recreates the table like this :
CREATE TABLE "table_name" ("new_key_name" integer, .... , PRIMARY KEY ("new_key_name" AUTOINCREMENT) )

DB4S Version

3.12.2

What OS are you seeing the problem on?

Windows

OS version

Windows 11

Relevant log output

Prevention against duplicate issues

  • I have searched for similar issues

Activity

  1. FriedrichFroebel commented on Jul 23, 2026

    @FriedrichFroebel
    Contributor

    Version 3.12.2 is rather old. Have you tried the latest release? While I see the schema change, I cannot see an issue with the auto-increment behavior afterwards.

  2. VxTedxV commented on Jul 24, 2026

    @VxTedxV
    Author

    Would like to but cannot test latest release due to policy from my employer.
    Do you mean you tried in QGis ? Should I provide screenshots from that software to show the difference ?

  3. chrisjlocke commented on Jul 24, 2026

    @chrisjlocke
    Member

    The create statement can be written in various ways.. The way db4s does it is not 'wrong' or incorrect.
    Have you tried adding a record in db4s to confirm the record increments correctly?

  4. FriedrichFroebel commented on Jul 24, 2026

    @FriedrichFroebel
    Contributor

    Do you mean you tried in QGis ? Should I provide screenshots from that software to show the difference ?

    I have not tested with QGis, but with DB4S, as this is the issue tracker for DB4S and I do not think that installing arbitrary software for this helps with this issue. The auto-increments work correctly with the changed schema in DB4S in the latest version and - as Chris mentioned - there are multiple ways to express CREATE statements. If you have to modify your third-party databases with DB4S and this leads to the database not being handled correctly externally while still using valid syntax, I would argue that the external application should fix it and not DB4S. For this reason, I am tempted to close this issue as invalid.

  5. VxTedxV commented on Jul 24, 2026

    @VxTedxV
    Author

    I understand. I still believe DB4S shouldn't change initial provided schema -> enhancement ?
    BTW, thanks for your answers !

  6. FriedrichFroebel commented on Jul 24, 2026

    @FriedrichFroebel
    Contributor

    I still believe DB4S shouldn't change initial provided schema

    With renaming columns, you are changing the schema, and in these cases I do not see an issue with using an equivalent "normalized" schema definition. While we could consider it an enhancement/feature request, given the current status about active maintenance this is unlikely of getting changed in the near future unless you are providing a straightforward patch yourself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions