Skip to content

Commit a4ff463

Browse files
[SqlQuery] Remove unused WhereColumn() (#514)
Closes #494. ## Summary `WhereColumn(left, op, right)` constructed a column-to-column comparison from two unqualified column names (e.g. `WhereColumn("left", "=", "right")` → `WHERE "left" = "right"`). Per #494 it is unused and unneeded — the same column-vs-column comparison is already expressible through the existing `Where(col, op, col)` overload (e.g. with `SqlQualifiedTableColumnName` operands, covered by the *"Where: SqlQualifiedTableColumnName OP SqlQualifiedTableColumnName"* test). ## Changes - **`SqlQuery/Core.hpp`** — removed the `WhereColumn` declaration and its out-of-line definition from `SqlWhereClauseBuilder<Derived>`. - **`tests/QueryBuilderTests.cpp`** — removed the obsolete `SqlQueryBuilder.WhereColumn` test case. No documentation referenced `WhereColumn`, and there were no internal callers (the unrelated `IsBatchUpdateWhereColumn` trait in `DataMapper.hpp` is a different identifier and is untouched). ## Risk assessment - **API**: breaking change for any external caller using `WhereColumn` — appropriate for the issue's intent. Migration: use `Where(left, op, right)` with `SqlQualifiedTableColumnName` operands for column-vs-column comparisons. - **Behavior**: no change to any other query-building path. - **Per-DBMS**: none — pure DSL surface removal, no SQL-generation differences. - **Performance**: none. ## Databases tested - `sqlite3` — `[SqlQueryBuilder]` green (395 assertions / 76 cases); full suite green (1196 passed, 1 skipped). - `mssql2022` (Docker, 16.00.4250) — `[SqlQueryBuilder]` green (396 assertions / 76 cases). - `postgres` — **skipped**: no PostgreSQL ODBC driver available in this environment. Low risk given the change is database-agnostic. Built via the `gcc-release` preset. Note: the `clang-debug` preset (clang-tidy + `-Werror`) currently fails on pre-existing findings in `master`'s recently-merged prefetch / ALTER-COLUMN commits (`SqlStatement.hpp`, `DataMapper.hpp`) that are unrelated to and untouched by this PR. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
2 parents db37b50 + 113e3d2 commit a4ff463

2 files changed

Lines changed: 0 additions & 32 deletions

File tree

src/Lightweight/SqlQuery/Core.hpp

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,6 @@ class [[nodiscard]] SqlWhereClauseBuilder
306306
template <typename ColumnName>
307307
[[nodiscard]] Derived& WhereFalse(ColumnName const& columnName);
308308

309-
/// Construts or extends a WHERE clause to test for a binary operation between two columns.
310-
template <typename LeftColumn, typename RightColumn>
311-
[[nodiscard]] Derived& WhereColumn(LeftColumn const& left, std::string_view binaryOp, RightColumn const& right);
312-
313309
/// Constructs an INNER JOIN clause.
314310
///
315311
/// @param joinTable The table's name to join with. This can be a string, a string_view, or an AliasedTableName.
@@ -758,24 +754,6 @@ inline LIGHTWEIGHT_FORCE_INLINE Derived& SqlWhereClauseBuilder<Derived>::WhereFa
758754
return Where(columnName, "=", false);
759755
}
760756

761-
/// Constructs or extends a WHERE clause to compare two columns.
762-
template <typename Derived>
763-
template <typename LeftColumn, typename RightColumn>
764-
inline LIGHTWEIGHT_FORCE_INLINE Derived& SqlWhereClauseBuilder<Derived>::WhereColumn(LeftColumn const& left,
765-
std::string_view binaryOp,
766-
RightColumn const& right)
767-
{
768-
AppendWhereJunctor();
769-
770-
AppendColumnName(left);
771-
SearchCondition().condition += ' ';
772-
SearchCondition().condition += binaryOp;
773-
SearchCondition().condition += ' ';
774-
AppendColumnName(right);
775-
776-
return static_cast<Derived&>(*this);
777-
}
778-
779757
template <typename T>
780758
struct WhereConditionLiteralType
781759
{

src/tests/QueryBuilderTests.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -933,16 +933,6 @@ TEST_CASE_METHOD(SqlTestFixture, "SqlQueryBuilder.Where.Lambda", "[SqlQueryBuild
933933
WHERE "a" = 1 OR ("b" = 2 AND "c" = 3))"));
934934
}
935935

936-
TEST_CASE_METHOD(SqlTestFixture, "SqlQueryBuilder.WhereColumn", "[SqlQueryBuilder]")
937-
{
938-
CheckSqlQueryBuilder(
939-
[](SqlQueryBuilder& q) {
940-
return q.FromTable("That").Select().Field("foo").WhereColumn("left", "=", "right").All();
941-
},
942-
QueryExpectations::All(R"(SELECT "foo" FROM "That"
943-
WHERE "left" = "right")"));
944-
}
945-
946936
TEST_CASE_METHOD(SqlTestFixture,
947937
"Where: SqlQualifiedTableColumnName OP SqlQualifiedTableColumnName",
948938
"[SqlQueryBuilder]")

0 commit comments

Comments
 (0)