Skip to content

fix: Prevent camelCase-to-colname to duplicate underscores (#1287) #1652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/utils/quoting.lisp
Original file line number Diff line number Diff line change
@@ -85,15 +85,18 @@
"Transform input STRING into a suitable column name.
lahmanID lahman_id
playerID player_id
birthYear birth_year"
birthYear birth_year
Reference_ID reference_id"
(coerce
(loop
:for first := t :then nil
:for char :across string
:for previous-upper-p := nil :then char-upper-p
:for previous-underscore := nil :then underscore
:for underscore := (char= char #\_)
:for char-upper-p := (and (alpha-char-p char)
(eq char (char-upcase char)))
:for new-word := (and (not first) char-upper-p (not previous-upper-p))
:when (and new-word (not (char= char #\_))) :collect #\_
:for new-word := (and (not first) char-upper-p (not previous-upper-p) (not previous-underscore))
:when new-word :collect #\_
:collect (char-downcase char))
'string))