From 14d395f0ea9526001eb926955562008d98a9523b Mon Sep 17 00:00:00 2001 From: wispem-wantex Date: Sat, 23 Aug 2025 15:53:23 -0700 Subject: [PATCH] Tidy up the Table SQL interface a bit --- pkg/schema/parse.go | 2 +- pkg/schema/table.go | 8 +++++--- pkg/schema/views.sql | 12 ++++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/pkg/schema/parse.go b/pkg/schema/parse.go index d6b5d5d..02c46fe 100644 --- a/pkg/schema/parse.go +++ b/pkg/schema/parse.go @@ -27,7 +27,7 @@ func SchemaFromDB(db *sqlx.DB) Schema { ret := Schema{} var tables []Table - err := db.Select(&tables, `select name, strict from tables`) + err := db.Select(&tables, `select name, is_strict, is_without_rowid from tables`) if err != nil { panic(err) } diff --git a/pkg/schema/table.go b/pkg/schema/table.go index da1818e..0d70468 100644 --- a/pkg/schema/table.go +++ b/pkg/schema/table.go @@ -21,9 +21,11 @@ func (c Column) IsNullableForeignKey() bool { // Table is a single SQLite table. type Table struct { - TableName string `db:"name"` - IsStrict bool `db:"strict"` - Columns []Column + TableName string `db:"name"` + IsStrict bool `db:"is_strict"` + IsWithoutRowid bool `db:"is_without_rowid"` + + Columns []Column TypeIDName string VarName string diff --git a/pkg/schema/views.sql b/pkg/schema/views.sql index 9936124..04d9fb8 100644 --- a/pkg/schema/views.sql +++ b/pkg/schema/views.sql @@ -1,8 +1,12 @@ create temporary view tables as - select l.schema, l.name, l.type, l.ncol, l.wr, l.strict - from sqlite_schema s - left join pragma_table_list l on s.name = l.name - where s.type = 'table'; + select l.schema, + l.name, + l.type, + l.wr as is_without_rowid, + l.strict as is_strict + from sqlite_schema s + left join pragma_table_list l on s.name = l.name + where s.type = 'table'; create temporary view columns as select tables.name as table_name,