sqlite_lint: add support for FTS5 and virtual tables
Some checks failed
CI / build-docker (push) Successful in 5s
CI / build-docker-bootstrap (push) Has been skipped
CI / release-test (push) Failing after 6s

This commit is contained in:
wispem-wantex
2026-01-17 09:00:18 +09:00
parent d70cbc1913
commit 0371fb4144
11 changed files with 68 additions and 36 deletions

View File

@@ -23,7 +23,10 @@ var Checks = []Check{
Explanation: "All columns should be marked as `not null` unless they are foreign keys. (Primary keys are\n" +
"automatically not-null, and don't need to be specified.)",
Execute: func(s schema.Schema) (ret []CheckResult) {
for tablename := range s.Tables {
for tablename, tbl := range s.Tables {
if tbl.TableType != "table" {
continue
}
for _, column := range s.Tables[tablename].Columns {
if !column.IsNotNull && !column.IsForeignKey && !column.IsPrimaryKey {
ret = append(ret, CheckResult{
@@ -43,7 +46,10 @@ var Checks = []Check{
"integer, real, text, blob or any). This disallows all 'date' and 'time' column types.\n" +
"See more: https://www.sqlite.org/stricttables.html",
Execute: func(s schema.Schema) (ret []CheckResult) {
for tablename := range s.Tables {
for tablename, tbl := range s.Tables {
if tbl.TableType != "table" {
continue
}
if !s.Tables[tablename].IsStrict {
ret = append(ret, CheckResult{
ErrorMsg: "Table should be marked \"strict\"",
@@ -78,7 +84,10 @@ var Checks = []Check{
Explanation: "All tables must have a primary key. If it's rowid, it has to be named explicitly.",
Execute: func(s schema.Schema) (ret []CheckResult) {
tableloop:
for tablename := range s.Tables {
for tablename, tbl := range s.Tables {
if tbl.TableType != "table" {
continue
}
for _, column := range s.Tables[tablename].Columns {
if column.IsPrimaryKey {
continue tableloop
@@ -161,6 +170,9 @@ var Checks = []Check{
Execute: func(s schema.Schema) (ret []CheckResult) {
tbl_loop:
for tblName, tbl := range s.Tables {
if tbl.TableType != "table" {
continue
}
if tbl.IsWithoutRowid {
continue
}

View File

@@ -5,6 +5,14 @@ create table stuff (
) strict;
create index index_stuff_amount on stuff (amount);
create virtual table stuff_fts using fts5(
data,
content='stuff',
content_rowid='rowid',
tokenize='trigram'
);
create table stuff2 (
weird_pk integer primary key,
label text not null unique,