Fork me on GitHub
#sql
<
2020-03-21
>
41ph4_Ph4un08:03:33

Hi! Has anyone experienced issues with usernames that have either "-" or "_" in them when using HikariCP with next.jdbc?

41ph4_Ph4un08:03:42

I'm currently experiencing weird behavior as when I connect to my PostgreSQL database without connection pools everything works fine, but when I add HikariCP into the equation I start getting errors like FATAL: no pg_hba.conf entry for host "192.168.99.1", user "foo", database "test-dev", SSL on, given I'd have username like foo-bar (for the sake of argument).

41ph4_Ph4un08:03:06

this behavior happens both for usernames that have "-" or "_" in them.

41ph4_Ph4un08:03:14

The authentication started to working when I modified all the usernames to not have those, but I have multiple infras with other tech stacks that work fine with PG and delimited usernames and I do like to use postfixes to differentiate users by type.

41ph4_Ph4un08:03:55

hmm.. it seems I get the same issue from com.impossibl.postgres.jdbc.PGDriver and org.postgresql.Driver

41ph4_Ph4un08:03:46

If I've understood correctly does that mean that the username get's malformed either by next.jdbc (I took a look at the code though, and to me it looks just fine!) or then by HikariCP?

41ph4_Ph4un09:03:47

aha! facepalm ... it seems that I had db-specwith :user instead of :username. goddamnit.. yeah forget it guys 😄

41ph4_Ph4un09:03:05

it somehow magically managed to connect without the pool when i had :user as the keyword for username

41ph4_Ph4un09:03:02

hmm.. actually that's a bit confusing.. so the documentations state that :user is used to define the connection username, yet when using connection pool the db-spec needs to use :username ? Is this documented somewhere?

41ph4_Ph4un09:03:46

oh lookie! it actually is! No problem there 😄 just needed to RTFM

seancorfield18:03:15

Yeah, it's a weirdness of HikariCP I'm afraid. I'm somewhat tempted to "fix" it by copying :user to :username in ->pool if the latter is omitted -- but I'm concerned I'll break something else, since that's generic and can be used with "any" connecting pooling class...

dharrigan12:03:09

Try to avoid - in username and database (and table etc..) names. Otherwise you'll be escaping them all, each time.

41ph4_Ph4un12:03:06

Yeah I'd definitely avoid them in tablenames. Usually I use specific naming for local dev infra that has some differentiation like '-dev' and '-test' for databases and same goes with some usernames (as I rarely type any queries manually that concern these) Production is different of course.

seancorfield18:03:15

Yeah, it's a weirdness of HikariCP I'm afraid. I'm somewhat tempted to "fix" it by copying :user to :username in ->pool if the latter is omitted -- but I'm concerned I'll break something else, since that's generic and can be used with "any" connecting pooling class...