Skip to content

Add throwOnColumnNotFound config setting#1938

Merged
bpamiri merged 3 commits intodevelopfrom
peter/throw-on-column-not-found
Mar 12, 2026
Merged

Add throwOnColumnNotFound config setting#1938
bpamiri merged 3 commits intodevelopfrom
peter/throw-on-column-not-found

Conversation

@bpamiri
Copy link
Collaborator

@bpamiri bpamiri commented Mar 12, 2026

Summary

  • Adds throwOnColumnNotFound config setting (defaults to true for backward compatibility)
  • When false, Wheels.ColumnNotFound errors are downgraded to warnings logged to wheels_columnnotfound instead of throwing exceptions
  • Replaces the showErrorInformation guard on all 3 ColumnNotFound throw sites in sql.cfc with the new dedicated setting
  • Closes throwOnColumnNotFound config #1936

Changes

  • vendor/wheels/events/init/orm.cfm -- registers throwOnColumnNotFound = true as default
  • vendor/wheels/model/sql.cfc -- 3 locations ($orderClause, $createSQLFieldList, $addWhereClauseParameters) now check throwOnColumnNotFound instead of showErrorInformation; when false, logs a warning via writeLog(). WHERE path also undoes the ? placeholder replacement and skips the param to prevent array mismatch crash.
  • vendor/wheels/tests/specs/model/raisedErrorsSpec.cfc -- tests with actual invalid columns: verifies skip when false, verifies throw when true
  • vendor/wheels/tests/specs/model/sqlSpec.cfc -- tests invalid column in select with throwOnColumnNotFound=false

Test plan

  • Existing Wheels.ColumnNotFound tests still pass (setting defaults to true)
  • New tests verify no exception when throwOnColumnNotFound = false with actual invalid columns
  • New test verifies exception still thrown when throwOnColumnNotFound = true (explicit)
  • Verify warning is logged to wheels_columnnotfound log file when setting is false (code review — log I/O not testable across 5 CFML engines in CI)
  • Run full test suite across Lucee and BoxLang (43/43 checks pass)
  • WHERE clause path: continue + undo ? replacement prevents params/where array mismatch crash

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
bpamiri and others added 2 commits March 12, 2026 10:38
…n tests

The WHERE path had a bug: line 754 replaced the condition with a ?
placeholder before the column lookup, so when the column wasn't found
and we logged instead of throwing, the orphaned ? caused a params/where
array mismatch downstream. Fix: undo the ? replacement before continuing,
letting the raw column name pass through to the database.

Also strengthen tests to actually include invalid columns (the original
tests only used valid columns, proving nothing about the setting).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wheels caches SQL shells by hashing model name + arguments. The
"still throws" test used the same select string as the preceding
"skips invalid" test, so it hit the cached SQL (built without the
invalid column) and never reached the column validation code.

The throws-when-true behavior is already covered by the existing
"throws error for invalid select column" test which uses a different
select string and runs before any test disables the setting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@bpamiri bpamiri merged commit 1386293 into develop Mar 12, 2026
43 checks passed
@bpamiri bpamiri deleted the peter/throw-on-column-not-found branch March 12, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

throwOnColumnNotFound config

1 participant