Grails validation does not work after upgrade

I am upgrading my Grails 1.3.7 application to 2.0.3, and I fixed most of the problems. However, I have a code that was used to work that creates a user and stores it in the database. The code should NOT pass validation, as I am reusing a username that has already been executed, and there is a unique restriction on the username. .validate()returns true, but then the code does indeed bomb when user.save()called with a unique MySql constraint error.

Should give an error:

def submitSignup = {
        def user = new User(params)

        user.validate()
        if (!user.hasErrors()) {
            ...
            // This line bombs with the MySql unique constraint I would have expected .validate() to get
            user.save()
        }
}

In User.groovy:

static constraints = {
    username(blank: false, unique: true);
    ...
}

Any ideas?

EDIT: I am also updating the Spring Security Plugin from Acegi. I do not think this would be relevant, but I thought that I would say this.

, : https://github.com/skazzaks/Grails-Unique-Test .

+5
2

, - , src/groovy.

0

1.3.7 2.0.3.

. -, .

, , , , .

+3

All Articles