Compare commits
No commits in common. "main" and "v1.5.10" have entirely different histories.
@ -1,8 +1,5 @@
|
|||||||
# 变更记录 - @go/db
|
# 变更记录 - @go/db
|
||||||
|
|
||||||
## [1.5.11] - 2026-08-22
|
|
||||||
- SQLite schema 同步支持删除定义中已经移除的字段,并同步处理影子删除表。
|
|
||||||
|
|
||||||
## [1.5.10] - 2026-08-13
|
## [1.5.10] - 2026-08-13
|
||||||
- 修复 schema 同步中的字段转义解析。
|
- 修复 schema 同步中的字段转义解析。
|
||||||
|
|
||||||
|
|||||||
10
Schema.go
10
Schema.go
@ -581,9 +581,6 @@ func (db *DB) CheckTable(table *TableStruct) error {
|
|||||||
for keyId := range oldIndexes {
|
for keyId := range oldIndexes {
|
||||||
if keyId != "PRIMARY" && !isPostgres && strings.ToLower(keySetFields[keyId]) != strings.ToLower(oldIndexes[keyId]) {
|
if keyId != "PRIMARY" && !isPostgres && strings.ToLower(keySetFields[keyId]) != strings.ToLower(oldIndexes[keyId]) {
|
||||||
if strings.HasPrefix(db.Config.Type, "sqlite") {
|
if strings.HasPrefix(db.Config.Type, "sqlite") {
|
||||||
if table.Name == "_Table" || table.Name == "_Field" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if strings.HasPrefix(keyId, "sqlite_autoindex_") {
|
if strings.HasPrefix(keyId, "sqlite_autoindex_") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -649,12 +646,7 @@ func (db *DB) CheckTable(table *TableStruct) error {
|
|||||||
|
|
||||||
for oldFieldName := range oldFields {
|
for oldFieldName := range oldFields {
|
||||||
if !newFieldExists[oldFieldName] {
|
if !newFieldExists[oldFieldName] {
|
||||||
if strings.HasPrefix(db.Config.Type, "sqlite") {
|
if !strings.HasPrefix(db.Config.Type, "sqlite") && !isPostgres {
|
||||||
if table.Name == "_Table" || table.Name == "_Field" {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
actions = append(actions, "ALTER TABLE "+db.Quote(table.Name)+" DROP COLUMN "+db.Quote(oldFieldName))
|
|
||||||
} else if !isPostgres {
|
|
||||||
actions = append(actions, "DROP COLUMN "+db.Quote(oldFieldName))
|
actions = append(actions, "DROP COLUMN "+db.Quote(oldFieldName))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,24 +42,6 @@ test_table SD // Test table with shadow delete
|
|||||||
if res.IntOnR1C1() != 1 {
|
if res.IntOnR1C1() != 1 {
|
||||||
t.Fatal("Shadow delete failed")
|
t.Fatal("Shadow delete failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
withoutStatus := `== Default ==
|
|
||||||
test_table SD // Test table with shadow delete
|
|
||||||
id AI // ID
|
|
||||||
name v50 U
|
|
||||||
autoVersion ubi // Version
|
|
||||||
`
|
|
||||||
if err := dbInst.Sync(withoutStatus); err != nil {
|
|
||||||
t.Fatal("Sync removed field:", err)
|
|
||||||
}
|
|
||||||
for _, tableName := range []string{"test_table", "test_table_deleted"} {
|
|
||||||
fields := dbInst.Query("PRAGMA table_info(" + dbInst.Quote(tableName) + ")").MapResults()
|
|
||||||
for _, field := range fields {
|
|
||||||
if field["name"] == "status" {
|
|
||||||
t.Fatalf("removed field remains in physical table %s", tableName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAutoDetectShadow(t *testing.T) {
|
func TestAutoDetectShadow(t *testing.T) {
|
||||||
|
|||||||
4
TEST.md
4
TEST.md
@ -1,9 +1,5 @@
|
|||||||
# @go/db 测试报告
|
# @go/db 测试报告
|
||||||
|
|
||||||
## v1.5.11 验证
|
|
||||||
- `TestSchemaSync` 覆盖 SQLite 主表与影子删除表的字段移除。
|
|
||||||
- `go test -v ./...` 与 `go test -bench=. ./...` 通过。
|
|
||||||
|
|
||||||
## v1.5.9 验证
|
## v1.5.9 验证
|
||||||
- `go list -m all`:模块图使用 `redis v1.5.11` 与稳定版 `redigo v1.9.3`。
|
- `go list -m all`:模块图使用 `redis v1.5.11` 与稳定版 `redigo v1.9.3`。
|
||||||
- `go test -v ./...`:通过完整测试。
|
- `go test -v ./...`:通过完整测试。
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user