done with wuditing with AI
This commit is contained in:
36
pgm_test.go
36
pgm_test.go
@@ -383,42 +383,6 @@ func TestConditionActionTypes(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestQueryBuilderReuse documents query builder reuse behavior
|
||||
// This test verifies that query builders accumulate state and should NOT be reused
|
||||
func TestQueryBuilderReuse(t *testing.T) {
|
||||
t.Skip("Query builders are not designed for reuse - this test documents the limitation")
|
||||
|
||||
// This test would require actual database tables to demonstrate the issue
|
||||
// The behavior is:
|
||||
// 1. Creating a base query builder
|
||||
// 2. Adding a WHERE clause
|
||||
// 3. Reusing the same builder with another WHERE clause
|
||||
// 4. The second query would have BOTH WHERE clauses
|
||||
//
|
||||
// Example:
|
||||
// baseQuery := users.User.Select(user.ID, user.Email)
|
||||
// baseQuery.Where(user.ID.Eq(1)) // First query
|
||||
// baseQuery.Where(user.Status.Eq(2)) // Second query has BOTH conditions!
|
||||
//
|
||||
// This is by design - query builders are mutable and single-use.
|
||||
// Each query should create a new builder instance.
|
||||
}
|
||||
|
||||
// TestQueryBuilderThreadSafety documents that query builders are not thread-safe
|
||||
func TestQueryBuilderThreadSafety(t *testing.T) {
|
||||
t.Skip("Query builders are not thread-safe by design - this test documents the limitation")
|
||||
|
||||
// Query builders accumulate state in their internal fields (where, args, etc.)
|
||||
// and do not use any synchronization primitives.
|
||||
//
|
||||
// Sharing a query builder across goroutines will cause race conditions.
|
||||
//
|
||||
// CORRECT usage: Create a new query builder in each goroutine
|
||||
// INCORRECT usage: Share a query builder variable across goroutines
|
||||
//
|
||||
// The connection pool itself IS thread-safe and can be used concurrently.
|
||||
}
|
||||
|
||||
// TestSelectQueryBuilderBasics tests basic query building
|
||||
func TestSelectQueryBuilderBasics(t *testing.T) {
|
||||
// Create a test table
|
||||
|
||||
Reference in New Issue
Block a user