@DbArray not allowing null to be persisted, stores empty list instead. #2844
Replies: 4 comments 6 replies
-
I think we are looking at #1867 ... which effectively introduced this behavior in ebean-agent 12.1.5 So more specifically, have you just upgraded from an Ebean version that was older than 12.1.5? (that's around Nov 2019) |
Beta Was this translation helpful? Give feedback.
-
Noting that this is the behavior of
I don't actually understand what you are saying there. Can you explain that in code form or have another go at explaining that? Maybe you are talking about multiple
Well it would be good to know what version of ebean this app has been upgraded from. If it is prior to 12.1.5 etc. If it is later than 12.1.5 I think we'd really like to see a test case to show the "before" behavior - perhaps fork the example minimal project - https://github.com/ebean-orm-examples/example-minimal |
Beta Was this translation helpful? Give feedback.
-
Sorry, I was away for almost two weeks. I will have too look at exact versions. It's a bit difficult to know because: we updated our stack of Java, Play, Play-Ebean, and thus ebean was transitive, and didn't notice this problem right away. I've tried downgrading Ebean, but at some point I recall that version of Ebean was not compatible with Java 17. I think this combo is still failing:
But this could be a state where 11.38.1 isn't Java 17 compatible and we stopped here, because downgrading Java is painful at this point and I was pretty sure there was a bug. However, at some point I was having trouble stopping sbt from overriding the ebean version. Our project has several modules, I think we had to change config in a lot of places. I'm unable to test right now, or I would. I read #1867 and it seems to be describe what I am seeing. The timing of that change could very well fit our timeframe. |
Beta Was this translation helpful? Give feedback.
-
Created this as an Issue: #2855 |
Beta Was this translation helpful? Give feedback.
-
Hello!
We are using ebean 13.1.0 on Postgres 14, unlike in some (all) prior versions, ebean seems to persist an empty list / array of cardinality of 0 in my postgres db, even if I explicitly set it to null.
This significantly breaks are code, because now a call to
myModel.update()
changes @DBArray fields to empty lists, marks the field as "dirty" (technically it now is dirty) and updates the db with an empty list.The weird thing is, I can't track/trap the code that is changing the value. In Intellij IDEA I can watch the value change from null to empty list in the debugger.
myModel.col1 = null;
# a watch on this field will show value of col1 as null [expected]myModel.col2 = null;
# a watch on this field will show value of col2 as null but automagically now col1 = {} (empty list) [very very unexpected and very annoying]`The fact I set
col2 = null
is irrelevant, I could have set it to anything and still col1 gets automatically set to empty list.One concrete scenario that breaks our application completely is where we don't even select 9 of 10 @DBArray fields from the db. We only want to select a single @DBArray field, transform the values, and update the db. In prior ebean versions, the non-selected field values were null (even if the db has values) and thus
update()
ignored them, as desired.Is this a bug? Can someone help me learn how I could have found the code automagically changing my fields in Intellij IDEA debugger? Stepping over code line by line didn't lead me to the code responsible.
Beta Was this translation helpful? Give feedback.
All reactions