-
-
Notifications
You must be signed in to change notification settings - Fork 264
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
String should default to text
field in Postgres
#3459
Comments
Following the JPA spec there to produce The question then becomes, should we not follow the JPA spec for Postgres and use One implication if we did that is for projects that support multiple database platforms like Postgres and SQL Server. That application would now have different behaviour between when using Postgres and when using SQL Server for the case when text larger than 255 characters is persisted. |
I guess it's a harder sell if the JPA spec is such. I personally would default to the suggested default so as to be most user friendly. But if the goal of the ORM and JPA is to have as exact reproducible behavior between databases as possible - then it makes sense. |
Note that today we can change the default mapping per type and platform like: Examplevar database = Database.builder()
.addCustomMapping(DbType.VARCHAR, "text", Platform.POSTGRES)
.build(); |
So pondering, if we made this change what would be the impact and how negative would it be? For the case of an application against a single database, then it would be nice for Postgres to default to For the case of an application that runs against multiple different database types that include Postgres, then there is the potential for Postgres to use (A) The workaround is to explicitly specify the length, and this is actually the right thing to do regardless for this multiple database case. (B) The default mapping of (C) This change would only apply to Postgres DDL going forward. It isn't changing or impacting any existing applications etc. Hmmm. |
Expected behavior
Should result in
Actual behavior
Should result in
Steps to reproduce
Just generate the code
Why?
It's PostgreSQL's official advice - https://wiki.postgresql.org/wiki/Don%27t_Do_This#Don.27t_use_varchar.28n.29_by_default
The text was updated successfully, but these errors were encountered: