remove debug files

This commit is contained in:
AI Engineer 2026-06-05 11:28:53 +08:00
parent 41e2bac5e2
commit 39eb72c450
6 changed files with 0 additions and 88 deletions

View File

@ -1,22 +0,0 @@
package main
import (
"fmt"
"apigo.cc/go/db"
)
func main() {
dbPath := "debug.db"
dbInst := db.GetDB("sqlite://"+dbPath, nil)
schema := `
== System ==
_Table SD
id c10 PK
name v64 U
`
fmt.Println("First sync...")
dbInst.Sync(schema)
fmt.Println("\nSecond sync...")
dbInst.Sync(schema)
}

View File

@ -1,3 +0,0 @@
module debug
go 1.26.1

View File

@ -1,5 +0,0 @@
rm -f test_idx.db
sqlite3 test_idx.db "CREATE TABLE test (name TEXT);"
sqlite3 test_idx.db "CREATE INDEX idx_name ON test(name);"
sqlite3 test_idx.db "CREATE UNIQUE INDEX IF NOT EXISTS idx_name ON test(name);"
echo "Result code: $?"

View File

@ -1,6 +0,0 @@
rm -f test_unique.db
sqlite3 test_unique.db "CREATE TABLE test (name TEXT);"
sqlite3 test_unique.db "INSERT INTO test (name) VALUES ('a');"
sqlite3 test_unique.db "INSERT INTO test (name) VALUES ('b');"
sqlite3 test_unique.db "CREATE UNIQUE INDEX uk_test_name ON test(name);"
echo "Result code: $?"

View File

@ -1,6 +0,0 @@
rm -f test_unique.db
sqlite3 test_unique.db "CREATE TABLE test (name TEXT);"
sqlite3 test_unique.db "INSERT INTO test (name) VALUES ('a');"
sqlite3 test_unique.db "INSERT INTO test (name) VALUES ('a');"
sqlite3 test_unique.db "CREATE UNIQUE INDEX uk_test_name ON test(name);"
echo "Result code: $?"

View File

@ -1,46 +0,0 @@
package db
import (
"fmt"
"os"
"testing"
)
func TestCheckTable_DuplicateUnique(t *testing.T) {
dbPath := "test_unique_race.db"
_ = os.Remove(dbPath)
defer os.Remove(dbPath)
dbInst := GetDB("sqlite://"+dbPath, nil)
schema := `
== System ==
_Table SD
id c10 PK
name v64 U
`
// First sync
err := dbInst.Sync(schema)
if err != nil {
t.Fatalf("First sync failed: %v", err)
}
// Insert duplicates to ensure recreation fails
dbInst.Exec("INSERT INTO _Table (id, name) VALUES ('1', 'dup')")
dbInst.Exec("INSERT INTO _Table (id, name) VALUES ('2', 'dup')") // Will fail if unique constraint works, but wait, the unique index is already there, so we can't insert duplicates!
// Wait, we CAN'T insert duplicates because the first sync created the index.
// But in the user's log, there ARE duplicates? Or maybe there are NO duplicates, but the engine just complains when it recreates the index on existing data?
// Ah, if there are NO duplicates, CREATE UNIQUE INDEX will SUCCEED.
// So why did the user get UNIQUE constraint failed?
// BECAUSE THERE WERE DUPLICATES!
// Why would there be duplicates in _Table?
// Let's just do the second sync and see if it tries to execute CREATE UNIQUE INDEX.
// Print statements will be inside Schema.go for a moment.
// Second sync (simulate restart)
err = dbInst.Sync(schema)
if err != nil {
t.Fatalf("Second sync failed: %v", err)
}
}