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

DB table ip field does not initialize value #4

bluepoet opened this Issue Jan 12, 2017 · 4 comments


None yet
2 participants
Copy link

bluepoet commented Jan 12, 2017



I initialized the value in the ip field of the DB table as below, but it does not contain the value.

 @DbUnit(configure = { IDatabaseTester it ->
        it.setUpOperation = DatabaseOperation.CLEAN_INSERT
def content = {
    User(name: 'test1', ip: '')
    User(name: 'test2', ip: '')

What should I do?

Please confirm.

Your help is very much appreciated!

@janbols janbols closed this Jan 12, 2017

@janbols janbols reopened this Jan 12, 2017


This comment has been minimized.

Copy link

janbols commented Jan 12, 2017

Hi, I don't know how your table looks like, what columns it has. Perhaps there's a PK somewhere that you didn't define. The way it's set up here it looks like you have a table called User with 2 columns called 'name' and 'ip'. If not, then that's probably the cause. I added a test containing your example that should pass on

Hope this helps.


This comment has been minimized.

Copy link

bluepoet commented Jan 13, 2017


Thank you for your response.

I have tried to execute the insert statement by changing the insert statement like below.

Def content = {
    User (name: 'test1', ip: '')
    User (name: 'test2')

If you insert the row data with the ip first, then the row data without the ip, the ip field will contain the value.
Probably the first thing you have to guess is that the insert sql statement that was executed was executed.

Please review below.


bluepoet pushed a commit to bluepoet/spock-dbunit that referenced this issue Jan 13, 2017

janbols added a commit that referenced this issue Jan 13, 2017

Merge pull request #5 from bluepoet/master
[#4]Add test code to check insert bug

This comment has been minimized.

Copy link

janbols commented Jan 13, 2017

Ok @bluepoet , I understand your problem now. The first row (in our case, the first User item) defines the columns dbUnit will use. So if you put User (name: 'test2') first, it will assume there's only 1 column. This is a flaw of dbUnit and I don't know if we can easily do something about this, though I agree it is rather annoying and I also bumped into the same issue before.


This comment has been minimized.

Copy link

janbols commented Mar 26, 2017

Closing this issue because it's not something we can do something about.

@janbols janbols closed this Mar 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment