Raw changeSet database related to boolean after grails 2.4.3 upgrade

I am using postgres database. After switching to grails 2.4.3, I get a set of database changes of this type for all logical fields:

changeSet(author: "me(generated)", id: "1383573084784-1") { addColumn(tableName: "chapter") { column(defaultValue: true, name: "is_framable", type: "boolean") { constraints(nullable: "false") } } } 

isFramable is the boolean field in the Chapter domain class. Even after starting this migration, it is generated every time by dbm-gorm-diff

I noticed that in older versions of grails, bool used instead of boolean instead of boolean in change sets

I am using hibernate version 4.3.5.5

+6
source share
2 answers

My workaround for this is:

Config.groovy

 grails.gorm.default.mapping = { "user-type" type: my.hibernate.type.BooleanBitType, class: boolean "user-type" type: my.hibernate.type.BooleanBitType, class: Boolean } 

BooleanBitType.java

 import my.hibernate.type.descriptor.BooleanBitTypeDescriptor; import org.hibernate.type.descriptor.java.BooleanTypeDescriptor; import org.hibernate.type.descriptor.sql.SqlTypeDescriptor; public class BooleanBitType extends org.hibernate.type.BooleanType { public static final BooleanBitType INSTANCE = new BooleanBitType(); public BooleanBitType() { this(BooleanBitTypeDescriptor.INSTANCE, BooleanTypeDescriptor.INSTANCE); } protected BooleanBitType(SqlTypeDescriptor sqlTypeDescriptor, BooleanTypeDescriptor javaTypeDescriptor) { super(sqlTypeDescriptor, javaTypeDescriptor); } } 

BooleanBitTypeDescriptor.java

 public class BooleanBitTypeDescriptor extends org.hibernate.type.descriptor.sql.BooleanTypeDescriptor { public static final BooleanBitTypeDescriptor INSTANCE = new BooleanBitTypeDescriptor(); public BooleanBitTypeDescriptor() { super(); } public int getSqlType() { return Types.BIT; } } 
+3
source

Error 2.5.4 still exists in grails. Gets Postgres users badly b / c postgres does not have an equivalent bit data type. It has a bit string that is not equivalent for storing boolean values. Grails docs suggest switching to char (1) version of Y / N inference.

'user-type' (type: org.hibernate.type.YesNoType, class: Boolean)

http://grails.imtqy.com/grails-doc/2.5.4/ref/Database%20Mapping/Usage.html

However, I do not like the idea of ​​bending my db scheme to accommodate errors in the application infrastructure.

So, I'll probably just ignore these unnecessary changes.

0
source

Source: https://habr.com/ru/post/976560/


All Articles