filer/sql: generators bind the arguments of row statements

Insert, update, find and delete now take the row key and return their
arguments with the query, so a generator decides how a key maps to its
columns.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011UpvafvK8JpagF94MHWqwK
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-01 16:34:58 -08:00
1 parent 88fb3c60eb
commit 4ae00a4728
8 files changed
+80 -45

No files matched your search

+4 -2
View File
@@ -3,11 +3,13 @@ package postgres
import (
"strings"
"testing"
"github.com/seaweedfs/seaweedfs/weed/filer/abstract_sql"
)
func TestDefaultUpsertQueryIsConflictSafe(t *testing.T) {
gen := &SqlGenPostgres{UpsertQueryTemplate: DefaultUpsertQuery}
got := gen.GetSqlInsert("filemeta")
got, _ := gen.GetSqlInsert("filemeta", abstract_sql.RowKey{}, nil)
if !strings.Contains(got, "ON CONFLICT") {
t.Fatalf("expected ON CONFLICT in default upsert, got: %s", got)
}
@@ -29,7 +31,7 @@ func TestDefaultCreateTableQueryRendersValidSql(t *testing.T) {
func TestEmptyUpsertTemplateFallsBackToPlainInsert(t *testing.T) {
gen := &SqlGenPostgres{}
got := gen.GetSqlInsert("filemeta")
got, _ := gen.GetSqlInsert("filemeta", abstract_sql.RowKey{}, nil)
if strings.Contains(got, "ON CONFLICT") {
t.Fatalf("plain INSERT path should not contain ON CONFLICT, got: %s", got)
}