mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-12-05 02:27:26 +01:00
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:
1 parent
88fb3c60eb
commit
4ae00a4728
8 files changed
+80
-45
No files matched your search
@@ -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)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user