Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 11, 2025

Column names like foo_25bar fail to round-trip through field name conversion, producing SQL errors when IHP attempts to reference foo25_bar instead of foo_25bar.

-- Before: broken round-trip
columnNameToFieldName "foo_25bar"  -- Uses Text.Inflections
  -- Result varies, but converting back produces "foo25_bar" ❌

-- After: correct round-trip  
columnNameToFieldName "foo_25bar"  -- "foo25bar"
fieldNameToColumnName "foo25bar"   -- "foo_25bar" ✓

Changes

columnNameToFieldName: Added custom logic when underscore precedes a digit

  • Pure digit segments (e.g., "123" from test_123_column) remain as-is; next word segment capitalized
  • Mixed digit-letter segments (e.g., "25bar" from foo_25bar) lowercased to encode boundary information

fieldNameToColumnName: Added custom logic for any field name containing digits

  • Inserts _ before digits following letters
  • Inserts _ before uppercase following lowercase only (not following digits, preserving encoded boundaries)

Test coverage

-- New round-trip tests
foo_25bar       foo25bar
test_123_column  test123Column  
user_2fa_enabled  user2faEnabled
item_3d_model    item3dModel

-- Existing behavior preserved
project_id  projectId
user_name   userName
Original prompt

This section details on the original issue you should resolve

<issue_title>round-trip error in underscore/titlecasing column names with number after underscore</issue_title>
<issue_description>
https://github.com/unhammer/ihp-back-button-repro/tree/noRoundtripTitleScore
does
ALTER TABLE users ADD COLUMN foo_25bar TEXT DEFAULT null;
which gives
EnhancedSqlError {sqlErrorQuery = "UPDATE users SET id = ?, name = ?, foo_25bar = ? WHERE id = ? RETURNING id, name, foo_25bar", sqlErrorQueryParams = [Plain "id",Escape "test",Plain "foo25_bar",Plain "'97cb49d9-2015-4121-bf55-885ef19dc4f0'"], sqlError = SqlError {sqlState = "42703", sqlExecStatus = FatalError, sqlErrorMsg = "column \"foo25_bar\" does not exist", sqlErrorDetail = "", sqlErrorHint = "Perhaps you meant to reference the column \"users.foo_25bar\"."}}
when trying to save an edit from e.g.
http://localhost:8002/EditUser?userId=97cb49d9-2015-4121-bf55-885ef19dc4f0

Yes I know it's a strange column name :-) but it would be nice if it either 1. worked or 2. was a compilation error.

possibly related:
#1497</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 3 commits December 11, 2025 16:20
Co-authored-by: mpscholten <2072185+mpscholten@users.noreply.github.com>
Co-authored-by: mpscholten <2072185+mpscholten@users.noreply.github.com>
Co-authored-by: mpscholten <2072185+mpscholten@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix round-trip error in underscore/titlecasing column names Fix round-trip conversion for column names with digits after underscores Dec 11, 2025
Copilot AI requested a review from mpscholten December 11, 2025 16:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

round-trip error in underscore/titlecasing column names with number after underscore

2 participants