Backlog: PostgreSQL schema not working -> rename dbSchema to defaultSchema #2724
Replies: 5 comments
-
Shouldn't |
Beta Was this translation helpful? Give feedback.
-
Not sure. |
Beta Was this translation helpful? Give feedback.
-
Ah, no that is not the intention here. Sorry, this is confusing and dealing with a very Postgres specific "convention" / "best practice" ... which is TLDR
That is, the motivation is more specifically with Postgres having a default
> ... there is no need to use currentSchema or modify the search path Said another way:
Under these conditions, we do NOT specify currentSchema, we do NOT modify the search path and we do NOT explicitly specify the schema in ... but the objects (tables, views etc) are put under that schema and NOT the Let's say our Postgres database username is Said another way, this is a Postgres specific convention, that if followed means that the objects do not go into the If we want to use a schema explicitly ... like Dang, I've probably not explained this well. Did any of the above help clarify? |
Beta Was this translation helpful? Give feedback.
-
It could almost be a boolean flag like When this is set to In order to make it a boolean, ebean would need to extract the database username when 1. running db migrations and 2. when the DdlRunner runs during testing. With this "kind of magic schema" / postgres specific convention the schema name must always match the database username / role. Implementation wise, instead of using a boolean and extracting the username, we've got a really poorly named |
Beta Was this translation helpful? Give feedback.
-
Ok, I'm going to move this into Discussions - Backlog. The task that should be done at some point is:
I'll move this to Discussions - Backlog as a kind of test to see how that workflow goes. |
Beta Was this translation helpful? Give feedback.
-
Expected behavior
Setting schema schould make effect on database connection:
https://ebean.io/docs/database/postgres/#schema
Actual behavior
Setting
databaseConfig.setDbSchema("test1")
does nothing, schema ispublic
.Comment
I have checked source code and is seems, that Ebean is setting property
schema
but Postgresql usescurrentSchema
.Setting
?currentSchema=test
in URL solves this problem.Source code from PostgreSQL JDBC driver ConnectionFactoryImpl.java:
And PGProperty.java:
I think, that
ConnectionPool.java
should be changed from:to:
Beta Was this translation helpful? Give feedback.
All reactions