| 1065 | /// types. |
| 1066 | pub fn force_coerced_if_record(&mut self) { |
| 1067 | fn convert(uncoerced_fields: impl Iterator<Item = CoercibleColumnType>) -> SqlScalarType { |
| 1068 | let mut fields = vec![]; |
| 1069 | for (i, uf) in uncoerced_fields.enumerate() { |
| 1070 | let name = ColumnName::from(format!("f{}", i + 1)); |
| 1071 | let ty = match uf { |
| 1072 | CoercibleColumnType::Coerced(ty) => ty, |
| 1073 | CoercibleColumnType::Record(mut fields) => { |
| 1074 | convert(fields.drain(..)).nullable(false) |
| 1075 | } |
| 1076 | CoercibleColumnType::Uncoerced => SqlScalarType::String.nullable(true), |
| 1077 | }; |
| 1078 | fields.push((name, ty)) |
| 1079 | } |
| 1080 | SqlScalarType::Record { |
| 1081 | fields: fields.into(), |
| 1082 | custom_id: None, |
| 1083 | } |
| 1084 | } |
| 1085 | |
| 1086 | if let CoercibleScalarType::Record(fields) = self { |
| 1087 | *self = CoercibleScalarType::Coerced(convert(fields.drain(..))); |