Default string size for Postgresql and Grails 3.3.8 seems to be 20 characters

465 views Asked by At

My string columns are defaulting to 20 characters. All the documentation suggests the default is 255. How do I set that without changing each individual column. I am using Grails 3.3.8 and Postgresql 9.3.

class DbConnection {
    String name
    String platform

creates 20 character columns If I add a mapping:

static mapping = {
    name sqlType: 'varchar(255)'
    platform sqlType: 'varchar(255)'
    url sqlType: 'varchar(255)'
}

I get the proper 255 characters, however, grails fails the string on validation:

Field error in object 'dop_etc.DbConnection' on field 'url': rejected value [localhost:5432/rbc48_fantasy]; codes [dop_etc.DbConnection.url.size.error.dop_etc.DbConnection.url,dop_etc.DbConnection.url.size.error.url,dop_etc.DbConnection.url.size.error.java.lang.String...

There seems to be a default size set somewhere and I can't seem to find it. Thanks for your responses.

1

There are 1 answers

0
bbyrd On

Apologies, found the problem in some pasted code (in application.groovy)

grails.gorm.default.constraints = {
    '*'(nullable: true, size: 1..255)
}

Here's the helpful article: Overriding default `maxSize` in domain class