mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-08 07:16:58 +02:00
fix: Prevent camelCase-to-colname to duplicate underscores
Fixes issue #1287
This commit is contained in:
parent
70f3557670
commit
119f01a2b7
@ -85,15 +85,18 @@
|
|||||||
"Transform input STRING into a suitable column name.
|
"Transform input STRING into a suitable column name.
|
||||||
lahmanID lahman_id
|
lahmanID lahman_id
|
||||||
playerID player_id
|
playerID player_id
|
||||||
birthYear birth_year"
|
birthYear birth_year
|
||||||
|
Reference_ID reference_id"
|
||||||
(coerce
|
(coerce
|
||||||
(loop
|
(loop
|
||||||
:for first := t :then nil
|
:for first := t :then nil
|
||||||
:for char :across string
|
:for char :across string
|
||||||
:for previous-upper-p := nil :then char-upper-p
|
: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)
|
:for char-upper-p := (and (alpha-char-p char)
|
||||||
(eq char (char-upcase char)))
|
(eq char (char-upcase char)))
|
||||||
:for new-word := (and (not first) char-upper-p (not previous-upper-p))
|
:for new-word := (and (not first) char-upper-p (not previous-upper-p) (not previous-underscore))
|
||||||
:when (and new-word (not (char= char #\_))) :collect #\_
|
:when new-word :collect #\_
|
||||||
:collect (char-downcase char))
|
:collect (char-downcase char))
|
||||||
'string))
|
'string))
|
||||||
|
Loading…
Reference in New Issue
Block a user