Repository: xataio/pgstream
Pull request #289 (2025-04-21 15:36:47)

Add table name and pg type oid to transformer data type error message

github-actions[bot]: ### Merging this branch will **not change** overall coverage

| Impacted Packages | Coverage Δ | :robot: |
|-------------------|------------|---------|
| github.com/xataio/pgstream/pkg/wal/processor/transformer | 82.11% (ø) |  |

---

<details>

<summary>Coverage by file</summary>

### Changed files (no unit tests)

| Changed File | Coverage Δ | Total | Covered | Missed | :robot: |
|--------------|------------|-------|---------|--------|---------|
| github.com/xataio/pgstream/pkg/wal/processor/transformer/wal_transformer_validator.go | 84.21% (ø) | 38 | 32 | 6 |  |

_Please note that the "Total", "Covered", and "Missed" counts above refer to ***code statements*** instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code._

</details>

github-actions[bot]: ### Merging this branch will **not change** overall coverage

| Impacted Packages | Coverage Δ | :robot: |
|-------------------|------------|---------|
| github.com/xataio/pgstream/pkg/wal/processor/transformer | 82.11% (ø) |  |

---

<details>

<summary>Coverage by file</summary>

### Changed files (no unit tests)

| Changed File | Coverage Δ | Total | Covered | Missed | :robot: |
|--------------|------------|-------|---------|--------|---------|
| github.com/xataio/pgstream/pkg/wal/processor/transformer/wal_transformer_validator.go | 84.21% (ø) | 38 | 32 | 6 |  |

_Please note that the "Total", "Covered", and "Missed" counts above refer to ***code statements*** instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code._

### Changed unit test files

- github.com/xataio/pgstream/pkg/wal/processor/transformer/wal_transformer_validator_test.go

</details>


Patch:
diff --git a/pkg/wal/processor/transformer/wal_transformer_validator.go b/pkg/wal/processor/transformer/wal_transformer_validator.go
index 0d5a508..7f87894 100644
--- a/pkg/wal/processor/transformer/wal_transformer_validator.go
+++ b/pkg/wal/processor/transformer/wal_transformer_validator.go
@@ -63,7 +63,7 @@ func (v *PostgresTransformerValidator) Validate(ctx context.Context, transformer
 				return fmt.Errorf("column %s not found in table %s", colName, schemaTable)
 			}
 			if !pgTypeCompatibleWithTransformerType(tr.CompatibleTypes(), datatype) {
-				return fmt.Errorf("transformer specified for column %s does not support pg data type", colName)
+				return fmt.Errorf("transformer specified for column '%s' in table %s does not support pg data type with oid: %d", colName, schemaTable, datatype)
 			}
 		}
 	}


Test patch:
diff --git a/pkg/wal/processor/transformer/wal_transformer_validator_test.go b/pkg/wal/processor/transformer/wal_transformer_validator_test.go
index 455c76c..2372fe4 100644
--- a/pkg/wal/processor/transformer/wal_transformer_validator_test.go
+++ b/pkg/wal/processor/transformer/wal_transformer_validator_test.go
@@ -198,7 +198,7 @@ func TestPostgresTransformerValidator(t *testing.T) {
 					},
 				},
 			},
-			wantErr: errors.New("transformer specified for column id does not support pg data type"),
+			wantErr: errors.New("transformer specified for column 'id' in table \"public\".\"test\" does not support pg data type with oid: "),
 		},
 		{
 			name: "error - column not found in table",
@@ -222,7 +222,7 @@ func TestPostgresTransformerValidator(t *testing.T) {
 
 			err := testPGValidator.Validate(context.Background(), tc.transformerMap)
 			if !errors.Is(err, tc.wantErr) {
-				require.Error(t, err, tc.wantErr.Error())
+				require.Contains(t, err.Error(), tc.wantErr.Error())
 			}
 		})
 	}