aboutsummaryrefslogtreecommitdiff
path: root/plan_test.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2026-07-17 19:35:55 +0200
committerStefan Majewsky <majewsky@gmx.net>2026-07-17 19:35:55 +0200
commit1383c6fbaa6b9e0b7cc5e44b74a905352d596758 (patch)
tree5aa59347be173f8c16ab9d8246e89def0a0aadcd /plan_test.go
parent3d1fce7b843891f789887655a9ce0c9ce1ace2de (diff)
downloadgo-oblast-1383c6fbaa6b9e0b7cc5e44b74a905352d596758.tar.gz
cache buildPlan results
Diffstat (limited to 'plan_test.go')
-rw-r--r--plan_test.go12
1 files changed, 10 insertions, 2 deletions
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"},
}