From 1383c6fbaa6b9e0b7cc5e44b74a905352d596758 Mon Sep 17 00:00:00 2001 From: Stefan Majewsky Date: Fri, 17 Jul 2026 19:35:55 +0200 Subject: cache buildPlan results --- plan_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'plan_test.go') diff --git a/plan_test.go b/plan_test.go index ae9e2cc..d6d6e65 100644 --- a/plan_test.go +++ b/plan_test.go @@ -39,6 +39,7 @@ func TestPlanFieldTraversal(t *testing.T) { // 6. traverses into "yetMoreTimestamps" as well (despite the extra pointer and the type being private) // 7. recognizes "id" as an autofilled column plan, err := buildPlan(reflect.TypeFor[Log](), PostgresDialect(), planOpts{ + StructTagKey: "db", TableName: "log_entries", PrimaryKeyColumnNames: []string{"id"}, }) @@ -65,6 +66,7 @@ func TestQueryConstructionBasic(t *testing.T) { CreatedAt time.Time `db:"CreatedAt"` } opts := planOpts{ + StructTagKey: "db", TableName: "basic_records", PrimaryKeyColumnNames: []string{"ID"}, } @@ -147,6 +149,7 @@ func TestQueryConstructionWithOnlyPrimaryKey(t *testing.T) { BarID int64 `db:"bar_id"` } opts := planOpts{ + StructTagKey: "db", TableName: "foo_bar_relations", PrimaryKeyColumnNames: []string{"foo_id", "bar_id"}, } @@ -227,7 +230,8 @@ func TestQueryConstructionWithoutPrimaryKey(t *testing.T) { BarID int64 `db:"bar_id"` } opts := planOpts{ - TableName: "foo_bar_relations", + StructTagKey: "db", + TableName: "foo_bar_relations", } t.Run("MariaDBDialect", func(t *testing.T) { @@ -305,7 +309,9 @@ func TestQueryConstructionImpossible(t *testing.T) { Foo int Bar *string } - opts := planOpts{} + opts := planOpts{ + StructTagKey: "db", + } testWith := func(dialect Dialect) func(*testing.T) { return func(t *testing.T) { @@ -344,6 +350,7 @@ func TestQueryConstructionWithMultiplePrimaryKeyColumns(t *testing.T) { CreatedAt time.Time `db:"created_at"` } opts := planOpts{ + StructTagKey: "db", TableName: "complex_records", PrimaryKeyColumnNames: []string{"group_id", "name"}, } @@ -425,6 +432,7 @@ func TestQueryConstructionWithMultipleAutoColumns(t *testing.T) { CreatedAt time.Time `db:"created_at,auto"` } opts := planOpts{ + StructTagKey: "db", TableName: "autogenerated_records", PrimaryKeyColumnNames: []string{"id"}, } -- cgit v1.3.1