Skip to content

Comments

Fix NULL being appended to SQL statements with no interpolations#341

Merged
rsslldnphy merged 1 commit intomainfrom
undefined-fix
Jan 31, 2026
Merged

Fix NULL being appended to SQL statements with no interpolations#341
rsslldnphy merged 1 commit intomainfrom
undefined-fix

Conversation

@rsslldnphy
Copy link
Member

Summary

  • Fixed a bug where plain SQL strings without interpolations (e.g., sql`SELECT * FROM posts`) would have "NULL" appended to them
  • The issue was caused by zip from es-toolkit padding arrays of different lengths with undefined, which was then converted to "NULL"
  • Extracted a processTemplateParts helper that properly handles the template literal structure

Test plan

  • All 25 existing tests pass
  • The specific failing test "appending to an empty SQLStatement" now passes
  • The "interpolating undefined" test still works correctly

🤖 Generated with Claude Code

The zip function from es-toolkit pads arrays of different lengths with
undefined. Since template literals always have one more fragment than
values, when there were no interpolated values, zip would pair the single
fragment with undefined, which then got converted to "NULL".

Extracted a processTemplateParts helper that properly handles the template
literal structure by pairing each value with its preceding fragment and
appending the final fragment separately.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

Coverage Report

  • orm-cli: 96.85%
  • orm-migrate: 94.02%
  • orm: 98.47%
  • sql: 97.03%
  • toolbox: 100%

@rsslldnphy rsslldnphy merged commit 2e08299 into main Jan 31, 2026
14 checks passed
@rsslldnphy rsslldnphy deleted the undefined-fix branch January 31, 2026 14:11
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.

1 participant