Repository navigation
Conversation
dariomazzitelli-sys
left a comment
There was a problem hiding this comment.
🤖 Hermes Agent — Code Review: PR #102 (SQL Server sink)
Build: ✅ 0 errores · Tests: ✅ 173 passed · 0 failed · 4 features builds sin regresiones
En general el SQL Server sink está MEJOR que el Oracle sink — usa el shared compute_schema_evolution_plan, maneja correctamente BEGIN/COMMIT/ROLLBACK, usa parámetros tipados para TDS, y tiene CHANGELOG actualizado.
Mejora global importante: el cambio en src/source/converter.rs (timestamp Value::String → Value::Timestamp(i64)) beneficia a TODOS los sinks.
Pero hay algunos issues. Detalles en los inline comments 👇
| @@ -0,0 +1,90 @@ | |||
| # SQL Server Sink Connector | |||
There was a problem hiding this comment.
🔴 Duplicate README: sql_server/README.md is a copy of sqlserver/README.md. Module is sqlserver/. Remove the duplicate.
| let sink = PostgresSink::new(config, mode)?; | ||
| Ok(Box::new(sink)) | ||
| } | ||
| #[cfg(feature = "sink-sqlserver")] |
There was a problem hiding this comment.
test_create_oracle_sink, this has no factory wiring test. Add one.
| // ── WHEN MATCHED THEN UPDATE SET ── | ||
| // Exclude PK columns (they are in the ON clause) and unchanged columns | ||
| // (Value::Unchanged from PG TOAST — must not overwrite with NULL). | ||
| sql.push_str("WHEN MATCHED THEN\n"); |
There was a problem hiding this comment.
🔴 Empty UPDATE SET: If all non-PK cols are Unchanged, SQL has UPDATE SET with nothing after — invalid T-SQL. Oracle PR omits the entire WHEN MATCHED clause when empty.
| }, | ||
| Value::Bool(b) => ParamOwned::Bool(*b), | ||
| Value::Int64(i) => ParamOwned::I64(*i), | ||
| Value::UInt64(u) => ParamOwned::String(u.to_string()), |
There was a problem hiding this comment.
NUMERIC(20,0) but value sent as NVARCHAR. Risks precision loss for values > 2^53.
| .naive_utc(), | ||
| ) | ||
| } | ||
| Value::Decimal(d) => ParamOwned::String(d.clone()), |
There was a problem hiding this comment.
String(d.clone()). Implicit conversion works but has perf implications.
| /// Dispatch primary on `DataType` (source-agnostic). SQL Server has no | ||
| /// equivalent of PG OID refinement, so this is a pure delegation to | ||
| /// `data_type_to_sqlserver`. | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
💡 Dead code: column_type() with #[allow(dead_code)] — never called. setup.rs uses data_type_to_sqlserver() directly.
| /// The placeholder does not vary by Value variant — all values use the | ||
| /// same `@P` convention. The caller is responsible for numbering and | ||
| /// binding the actual value through tiberius. | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
💡 Dead code: value_to_param() with #[allow(dead_code)] — never called. Params built via value_to_param_owned().
| /// Each null variant carries the correct TDS type so SQL Server doesn't | ||
| /// reject it with "Operand type clash" when the column expects e.g. | ||
| /// DATETIME2 (naively sending `Option<i32>` as int NULL). | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
💡 Unnecessary #[allow(dead_code)]: All ParamOwned variants are constructed in value_to_param_owned(). Lint override not needed.
|
|
||
| | Variable | Description | Default | | ||
| |----------|-------------|---------| | ||
| | `SINK_URL` | SQL Server hostname or IP | required | |
There was a problem hiding this comment.
SINK_URL but code uses SINK_HOST. Example config looks copied from another sink.
| records_written, bytes_written | ||
| ); | ||
|
|
||
| Ok(SinkResult { |
There was a problem hiding this comment.
dariomazzitelli-sys
left a comment
There was a problem hiding this comment.
🤖 Hermes Agent — Code Review (English)
Build: ✅ 0 errors · Tests: ✅ 173/173 pass · Has CHANGELOG ✅
Better than the Oracle PR — uses shared compute_schema_evolution_plan, proper BEGIN/COMMIT/ROLLBACK, typed TDS parameters. However:
🔴 Out-of-scope change: src/source/converter.rs modifies timestamp handling (OIDs 1114, 1184 → Value::Timestamp(i64)) for ALL sinks, not just SQL Server. This should be a separate PR.
See inline comments for code-specific findings.
| @@ -0,0 +1,90 @@ | |||
| # SQL Server Sink Connector | |||
There was a problem hiding this comment.
🔴 Duplicate README: This file at sql_server/README.md is an exact copy of sqlserver/README.md. The module lives at sqlserver/ (no underscore). Remove this duplicate.
| // ── WHEN MATCHED THEN UPDATE SET ── | ||
| // Exclude PK columns (they are in the ON clause) and unchanged columns | ||
| // (Value::Unchanged from PG TOAST — must not overwrite with NULL). | ||
| sql.push_str("WHEN MATCHED THEN\n"); |
There was a problem hiding this comment.
🔴 Empty UPDATE SET clause: If all non-PK columns are Value::Unchanged, set_parts is empty and SQL produces WHEN MATCHED THEN\n UPDATE SET\n WHEN NOT MATCHED... — invalid T-SQL. Oracle PR (#101) omits the entire UPDATE clause when there's nothing to update.
| }, | ||
| Value::Bool(b) => ParamOwned::Bool(*b), | ||
| Value::Int64(i) => ParamOwned::I64(*i), | ||
| Value::UInt64(u) => ParamOwned::String(u.to_string()), |
There was a problem hiding this comment.
Value::UInt64(u) => ParamOwned::String(u.to_string()). DDL creates NUMERIC(20, 0) but value is sent as NVARCHAR. Implicit conversion works but risks precision loss for values > 2^53.
| .naive_utc(), | ||
| ) | ||
| } | ||
| Value::Decimal(d) => ParamOwned::String(d.clone()), |
There was a problem hiding this comment.
Value::Decimal(d) => ParamOwned::String(d.clone()). Tiberius has no native rust_decimal::Decimal type. Sent as NVARCHAR — implicit conversion works but has performance and precision implications.
| DataType::UInt64 => "NUMERIC(20, 0)", | ||
| DataType::Float32 => "REAL", | ||
| DataType::Float64 => "FLOAT(53)", | ||
| DataType::Decimal { |
There was a problem hiding this comment.
"NUMERIC(38, 0)" regardless of actual precision/scale. If source has DECIMAL(10, 2), target gets NUMERIC(38, 0) — truncating scale. Use DataType::Decimal { precision, scale } => format!("NUMERIC({}, {})", precision, scale).
| /// The placeholder does not vary by Value variant — all values use the | ||
| /// same `@P` convention. The caller is responsible for numbering and | ||
| /// binding the actual value through tiberius. | ||
| #[allow(dead_code)] |
There was a problem hiding this comment.
💡 Dead code: value_to_param() with #[allow(dead_code)] — never called. Params built via value_to_param_owned() and build_params() in mod.rs.
|
|
||
| | Variable | Description | Default | | ||
| |----------|-------------|---------| | ||
| | `SINK_URL` | SQL Server hostname or IP | required | |
There was a problem hiding this comment.
SINK_URL but config.rs uses SINK_HOST for SQL Server (not SINK_URL). The username/password/env vars in the example look like they were copied from another sink. Fix to reflect actual SQL Server configuration.
Connector sql_server sink generado por la factory EZ-CDC.
feat/sql_server-sink-20260611182837-ceac93dbmazz-sqlserver:devPR automático (no mergear sin review).