apache / apache/grails-core

default column values are incorrectly handled by diffs

Open
#14,477 6 comments 3 reactions 0 assignees View on GitHub
relates-to: grails-data-hibernate5
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

Given

```
class Apple{
Boolean isGood = false

static mapping = {
isGood defaultValue: false
}
}
```
a. I have to hand correct the diff to add defaultvalueboolean:

` changeSet(author: "me (generated)", id: "1486375845934-1") {
addColumn(tableName: "apple") {
column(name: "is_good", type: "boolean", defaultValueBoolean: false) {
constraints(nullable: "false")
}
}
}`

b. After applying update, the next diff will try to remove it

```
changeSet(author: "me (generated)", id: "1486614694673-15") {
dropDefaultValue(columnDataType: "boolean", columnName: "is_good", tableName: "apple")
}
```

So basically, the plugin (or underlying libraries) break default values.

http://docs.grails.org/3.1.14/ref/Database%20Mapping/column.html

----
runtime 'org.grails.plugins:database-migration:2.0.0
grails 3.1.14
postgres 9.6
java 8

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the shown Grails mapping using database-migration 2.0.0, Grails 3.1.14, PostgreSQL 9.6, and Java 8. Start by comparing the generated changesets before and after applying the update. Done means the boolean default is represented correctly in the initial diff and a later diff does not remove it.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy, postgresql
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.