release: v2.1.4 isolated HTTP execute (ADR 0009)

Default execute/sse-live/stream to Supervisor worker pool; MR-01 gold;
/_runtime/*; bump CLI/wasm/ext to 2.1.4.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-10-26 18:33:33 +08:00
1 parent 58e13ee6d3
commit 3cabe53da2
56 files changed
+4957 -304

No files matched your search

+48
View File
@@ -968,6 +968,54 @@ func Update(url, tableName, id string, row any, txnID ...string) (map[string]any
return map[string]any{"ok": true, "updated": float64(n)}, nil
}
// UpdateIf is a conditional update (CAS): SET row WHERE id=? AND expect_col=expect_val.
// Returns {"ok":true,"updated":N,"matched":N}. Callers treat updated==0 as conflict.
// Optional txnID routes through an open Begin transaction.
func UpdateIf(url, tableName, id string, row any, expectCol string, expectVal any, txnID ...string) (map[string]any, error) {
tn, err := ident(tableName)
if err != nil {
return nil, err
}
ecol, err := ident(expectCol)
if err != nil {
return nil, err
}
obj, ok := row.(map[string]any)
if !ok {
return nil, fmt.Errorf("row must be a map")
}
c, err := connFor(url, optTxn(txnID))
if err != nil {
return nil, err
}
var sets []string
var vals []any
for k, v := range obj {
if k == "id" {
continue
}
if _, err := ident(k); err != nil {
return nil, err
}
sets = append(sets, fmt.Sprintf(`"%s" = ?`, k))
vals = append(vals, toSQLArg(v))
}
if len(sets) == 0 {
return nil, fmt.Errorf("nothing to update")
}
vals = append(vals, id, toSQLArg(expectVal))
sqlStmt := fmt.Sprintf(
`UPDATE "%s" SET %s WHERE "id" = ? AND "%s" = ?`,
tn, strings.Join(sets, ", "), ecol,
)
res, err := c.Exec(sqlStmt, vals...)
if err != nil {
return nil, err
}
n, _ := res.RowsAffected()
return map[string]any{"ok": true, "updated": float64(n), "matched": float64(n)}, nil
}
// Delete removes a row by id. Returns {"ok":true,"deleted":N}.
// Optional txnID routes through an open Begin transaction.
func Delete(url, tableName, id string, txnID ...string) (map[string]any, error) {
+18
View File
@@ -100,6 +100,24 @@ func TestInitInsertSelectGet(t *testing.T) {
}
}
func TestUpdateIfCAS(t *testing.T) {
url := setupArticles(t)
ok, err := db.UpdateIf(url, "articles", "1", map[string]any{"title": "CAS"}, "title", "Alpha")
if err != nil {
t.Fatal(err)
}
if ok["updated"] != float64(1) {
t.Fatalf("cas hit=%v", ok)
}
miss, err := db.UpdateIf(url, "articles", "1", map[string]any{"title": "Nope"}, "title", "Alpha")
if err != nil {
t.Fatal(err)
}
if miss["updated"] != float64(0) {
t.Fatalf("cas miss should be 0, got %v", miss)
}
}
func TestUpdateDelete(t *testing.T) {
url := setupArticles(t)