Bandaid fix for unexpected additional records.
@@ -126,11 +126,19 @@ fn serialize_record_selection(
.map(|(parent, mut items)| {
// As it's not a list, we require a single result
if items.len() > 1 {
+ items.reverse();
+ let first = items.pop().unwrap();
+
+ // [DTODO] Workaround for incredibly hard to follow 1:m read relation issue that produces multiple identical records.
+ if items.iter().all(|i| i == &first) {
+ Ok((parent, Item::Ref(ItemRef::new(items.pop().unwrap()))))
+ } else {
Err(CoreError::SerializationError(format!(
"Expected at most 1 item for '{}', got {}",
name,
- items.len()
+ items.len() + 1
)))
+ }
} else if items.is_empty() && opt {
Ok((parent, Item::Ref(ItemRef::new(Item::Value(PrismaValue::Null)))))
} else if items.is_empty() && opt {
