Skip to content

lowercase app name when generating postgres db name#88

Merged
snoyberg merged 2 commits intosnoyberg:masterfrom
rvion:lowercase-appname-when-generating-db-name-in-postgres-plugin-v2
Apr 8, 2015
Merged

lowercase app name when generating postgres db name#88
snoyberg merged 2 commits intosnoyberg:masterfrom
rvion:lowercase-appname-when-generating-db-name-in-postgres-plugin-v2

Conversation

@rvion
Copy link
Copy Markdown
Contributor

@rvion rvion commented Apr 8, 2015

Lowercase appname when generating db name in postgres plugin
Branch made from issue #86
supersede pr #87

also applied Hlint suggestion

  • remove redundant do
  • merge two imports statements into one

@rvion
Copy link
Copy Markdown
Contributor Author

rvion commented Apr 8, 2015

@tolysz I left T.toLower instead of lowering the char in the filter both because of readability and because it seems that Text.toLower handle more cases than map Char.toLower
doc says
O(n) Convert a string to lower case, using simple case conversion. The result string may be longer than the input string. For instance, "İ" (Latin capital letter I with dot above, U+0130) maps to the sequence "i" (Latin small letter i, U+0069) followed by " ̇" (combining dot above, U+0307).

Still not sure it is the way to go, and anyway, build fails so more is to be done anyway.
Leaving as-is

@snoyberg
Copy link
Copy Markdown
Owner

snoyberg commented Apr 8, 2015

Since you're only dealing with ASCII letters (A-Z), there shouldn't be any difference in behavior. I don't have an opinion on which form looks nicer TBH.

@snoyberg
Copy link
Copy Markdown
Owner

snoyberg commented Apr 8, 2015

Can I ask you to ping me when you think this is ready to be merged? I'm taking from your comment that you still are going to make a few changes.

@tolysz
Copy link
Copy Markdown
Contributor

tolysz commented Apr 8, 2015

Sure, but we already have only [a-zA-Z_] at the time of T.toLower application and those do not benefit from full unicode normalization.

@rvion rvion force-pushed the lowercase-appname-when-generating-db-name-in-postgres-plugin-v2 branch from 8b6393d to 77a9198 Compare April 8, 2015 07:34
@rvion
Copy link
Copy Markdown
Contributor Author

rvion commented Apr 8, 2015

@tolysz that's why I then switched in my second PR to T.map sanitize' . T.toLower .

Anyway, in this third version, I did what you wanted - code is now:

    sanitize = T.map sanitize'
    sanitize' c
        | 'A' <= c && c <= 'Z' = C.toLower c
        | 'a' <= c && c <= 'z' = c
        | '0' <= c && c <= '9' = c
        | otherwise = '_'

@snoyberg it can me berged (build is passing except on 7.4 because iproute-1.4.0 dependency failed to install)

@tolysz
Copy link
Copy Markdown
Contributor

tolysz commented Apr 8, 2015

Beautiful :)

@snoyberg snoyberg merged commit 77a9198 into snoyberg:master Apr 8, 2015
@snoyberg
Copy link
Copy Markdown
Owner

snoyberg commented Apr 8, 2015

Thanks!

@MaxGabriel
Copy link
Copy Markdown
Contributor

Should this same change of lowercasing the app name be applied to the scaffolding, specifically this part" https://github.com/yesodweb/yesod-scaffold/blob/df45cb46ff4c7c1dd9b41ad30ea847f6fef9d4c8/config/settings.yml#L25

@snoyberg
Copy link
Copy Markdown
Owner

Yeah, that makes sense. I'll make that change, there's something slightly (though not significantly) tricky that needs to happen there.

@tolysz
Copy link
Copy Markdown
Contributor

tolysz commented Apr 13, 2015

Hi,
I do not know :) but I think it has only isues with generated username/password.
But I checked by changing dbname to rAndOmcAse and it works
edit: just lowercase the user name is enough:
( http://www.postgresql.org/message-id/201004191852.o3JIqiMK012314@wwwmaster.postgresql.org )

@snoyberg
Copy link
Copy Markdown
Owner

Scratch that, @tolysz's right I think, mixed case seems to be just fine.

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.

4 participants