feat(resolvemcp): replace per-model tools with fixed meta tools, guarded filter writes and a function registry

Tools: list_tables, describe_table, select_table, insert_into_table, update_table,
delete_from_table, list_functions, call_function. Visibility follows the model rules.
Filter-based update/delete require filters (never dropped silently), cap the matched rows
(MaxWriteRows), support dry_run, and need a single-use confirm token bound to caller, table,
filters, data and the matched rows. RegisterFunction adds Go-callback and SQL-procedure
functions run in a transaction with BeforeCall/AfterCall hooks. Per-model tools and
resources are removed.

fix(pgsql): UPDATE with SET and a multi-placeholder WHERE renumbered the WHERE parameters
wrongly ($1, $2 became $3, $2); shift them in one pass.
This commit is contained in:
Hein
2026-10-01 13:40:00 +02:00
parent 276c3814d8
commit e49c3a916e
11 changed files with 1562 additions and 370 deletions
@@ -627,3 +627,23 @@ func TestRawSQL(t *testing.T) {
assert.NoError(t, mock.ExpectationsWereMet())
}
// WHERE placeholders must be shifted past the SET parameters without rewriting numbers the
// shift itself produced: "a = ? AND b = ?" must stay in order.
func TestPgSQLUpdateQuery_WherePlaceholdersAfterSet(t *testing.T) {
db, mock, err := sqlmock.New()
require.NoError(t, err)
defer db.Close()
mock.ExpectExec(`UPDATE users SET name = \$1 WHERE a = \$2 AND b = \$3 AND "id" IN \(\$4, \$5\)`).
WithArgs("n", 10, 20, 7, 8).
WillReturnResult(sqlmock.NewResult(0, 2))
adapter := NewPgSQLAdapter(db)
_, err = adapter.NewUpdate().Table("users").SetMap(map[string]interface{}{"name": "n"}).
Where("a = ? AND b = ?", 10, 20).
Where(`"id" IN (?, ?)`, 7, 8).
Exec(context.Background())
require.NoError(t, err)
require.NoError(t, mock.ExpectationsWereMet())
}