(prop: EntityProperty<T>, row: Dictionary)
| 1201 | } |
| 1202 | |
| 1203 | const addParams = (prop: EntityProperty<T>, row: Dictionary) => { |
| 1204 | const rowValue = row[prop.name]; |
| 1205 | |
| 1206 | if (prop.nullable && rowValue === null) { |
| 1207 | params.push(null); |
| 1208 | return; |
| 1209 | } |
| 1210 | |
| 1211 | let value = rowValue ?? prop.default; |
| 1212 | |
| 1213 | if (prop.kind === ReferenceKind.EMBEDDED && prop.object) { |
| 1214 | if (prop.array && value) { |
| 1215 | value = this.platform.cloneEmbeddable(value); |
| 1216 | |
| 1217 | for (let i = 0; i < (value as Dictionary[]).length; i++) { |
| 1218 | const item = (value as Dictionary[])[i]; |
| 1219 | value[i] = this.mapDataToFieldNames(item, false, prop.embeddedProps, options.convertCustomTypes); |
| 1220 | } |
| 1221 | } else { |
| 1222 | value = this.mapDataToFieldNames(value, false, prop.embeddedProps, options.convertCustomTypes); |
| 1223 | } |
| 1224 | } |
| 1225 | |
| 1226 | if (typeof value === 'undefined' && this.platform.usesDefaultKeyword()) { |
| 1227 | params.push(raw('default')); |
| 1228 | return; |
| 1229 | } |
| 1230 | |
| 1231 | if (options.convertCustomTypes && prop.customType) { |
| 1232 | params.push( |
| 1233 | prop.customType.convertToDatabaseValue(value, this.platform, { key: prop.name, mode: 'query-data' }), |
| 1234 | ); |
| 1235 | return; |
| 1236 | } |
| 1237 | |
| 1238 | params.push(value); |
| 1239 | }; |
| 1240 | |
| 1241 | if (fields.length > 0 || this.platform.usesDefaultKeyword()) { |
| 1242 | sql += data |
no test coverage detected