restructuring of files. added 2 new methods(Asc, Desc) to field

This commit is contained in:
2025-10-18 12:31:46 +05:30
parent 6f5748d3d3
commit 325103e8ef
13 changed files with 433 additions and 446 deletions

View File

@@ -3,7 +3,6 @@ package playground
import (
"testing"
"code.patial.tech/go/pgm"
"code.patial.tech/go/pgm/playground/db"
"code.patial.tech/go/pgm/playground/db/user"
)
@@ -27,28 +26,8 @@ func TestUpdateQuery(t *testing.T) {
}
}
func TestUpdateSetMap(t *testing.T) {
got := db.User.Update().
SetMap(map[pgm.Field]any{
user.FirstName: "ankit",
user.MiddleName: "singh",
user.LastName: "patial",
}).
Where(
user.Email.Eq("aa@aa.com"),
).
Where(
user.StatusID.NotEq(1),
).
String()
expected := "UPDATE users SET first_name=$1, middle_name=$2, last_name=$3 WHERE users.email = $4 AND users.status_id != $5"
if got != expected {
t.Errorf("\nexpected: %q\ngot: %q", expected, got)
}
}
// BenchmarkUpdateQuery-12 2004985 592.2 ns/op 1176 B/op 20 allocs/op
// BenchmarkUpdateQuery-12 1792483 670.7 ns/op 1176 B/op 20 allocs/op
func BenchmarkUpdateQuery(b *testing.B) {
for b.Loop() {
_ = db.User.Update().