Skip to content

fix(db): detect auto_increment for SQLite INTEGER PRIMARY KEY#44

Merged
Lazialize merged 1 commit intomainfrom
fix/28-sqlite-auto-increment-export
Feb 8, 2026
Merged

fix(db): detect auto_increment for SQLite INTEGER PRIMARY KEY#44
Lazialize merged 1 commit intomainfrom
fix/28-sqlite-auto-increment-export

Conversation

@Lazialize
Copy link
Owner

Summary

SQLiteのINTEGER PRIMARY KEYカラムのauto_increment属性がstrata export時に失われる問題を修正。

SQLiteではINTEGER PRIMARY KEYは暗黙的にROWIDのエイリアスとなり自動増分するが、イントロスペクターは明示的なAUTOINCREMENTキーワードがDDLに含まれている場合のみauto_incrementを検出していた。Strataのgenerate_create_tableAUTOINCREMENTキーワードを生成しないため、generateapplyexportのラウンドトリップでauto_increment: trueが常に失われていた。

修正内容: INTEGER型かつPRIMARY KEYのカラムであれば、AUTOINCREMENTキーワードの有無に関わらずauto_increment: trueとして検出するよう変更。

Related Issue

Fixes #28

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation update
  • CI/CD or tooling changes

Test Plan

  • Added/updated unit tests
  • Tested manually with PostgreSQL
  • Tested manually with MySQL
  • Tested manually with SQLite

Checklist

  • My code follows the project's coding style
  • I have run cargo fmt and cargo clippy
  • I have added tests that prove my fix/feature works
  • All new and existing tests pass (cargo test)
  • I have updated documentation if needed

…CREMENT keyword in SQLite export

In SQLite, INTEGER PRIMARY KEY columns are implicitly ROWID aliases and
auto-incrementing, regardless of whether the AUTOINCREMENT keyword is
present in the DDL. The introspector previously only detected
auto_increment when the explicit AUTOINCREMENT keyword was found in
the CREATE TABLE SQL, causing the attribute to be lost during export.

Fixes #28

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Lazialize Lazialize merged commit b632969 into main Feb 8, 2026
1 check passed
@Lazialize Lazialize deleted the fix/28-sqlite-auto-increment-export branch February 8, 2026 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

export: SQLite auto_increment is lost during schema export

1 participant