Test InsertStatement pool
(t *testing.T)
| 22 | |
| 23 | // Test InsertStatement pool |
| 24 | func TestInsertStatementPool(t *testing.T) { |
| 25 | t.Run("Get and Put", func(t *testing.T) { |
| 26 | // Get from pool |
| 27 | stmt := GetInsertStatement() |
| 28 | if stmt == nil { |
| 29 | t.Fatal("GetInsertStatement() returned nil") |
| 30 | } |
| 31 | |
| 32 | // Use it |
| 33 | stmt.TableName = "users" |
| 34 | stmt.Columns = []Expression{ |
| 35 | &Identifier{Name: "name"}, |
| 36 | &Identifier{Name: "email"}, |
| 37 | } |
| 38 | // Values is now [][]Expression for multi-row support |
| 39 | stmt.Values = [][]Expression{ |
| 40 | { |
| 41 | &LiteralValue{Value: "John"}, |
| 42 | &LiteralValue{Value: "john@example.com"}, |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | // Return to pool |
| 47 | PutInsertStatement(stmt) |
| 48 | |
| 49 | // Verify it was cleaned |
| 50 | if stmt.TableName != "" { |
| 51 | t.Errorf("TableName not cleared, got %v", stmt.TableName) |
| 52 | } |
| 53 | if len(stmt.Columns) != 0 { |
| 54 | t.Errorf("Columns not cleared, len = %d", len(stmt.Columns)) |
| 55 | } |
| 56 | if len(stmt.Values) != 0 { |
| 57 | t.Errorf("Values not cleared, len = %d", len(stmt.Values)) |
| 58 | } |
| 59 | }) |
| 60 | |
| 61 | t.Run("Put nil statement", func(t *testing.T) { |
| 62 | // Should not panic |
| 63 | PutInsertStatement(nil) |
| 64 | }) |
| 65 | } |
| 66 | |
| 67 | // Test UpdateStatement pool |
| 68 | func TestUpdateStatementPool(t *testing.T) { |
nothing calls this directly
no test coverage detected