|
16 | 16 | limitations under the License. |
17 | 17 | ----------------------------------------------------------------- |
18 | 18 | """ |
19 | | - |
| 19 | +fromcontextlibimportsuppress |
20 | 20 | fromtypingimportClassVar,Optional,Union |
21 | 21 |
|
22 | 22 | fromapp.translator.constimportDEFAULT_VALUE_TYPE |
@@ -229,23 +229,26 @@ def generate_from_tokenized_query_container(self, query_container: TokenizedQuer |
229 | 229 | errors= [] |
230 | 230 | source_mappings=self._get_source_mappings(query_container.meta_info.source_mapping_ids) |
231 | 231 |
|
232 | | -forsource_mappinginsource_mappings: |
| 232 | +last_mapping_index=len(source_mappings)-1 |
| 233 | +forindex,source_mappinginenumerate(source_mappings): |
233 | 234 | try: |
234 | 235 | finalized_query=self._generate_from_tokenized_query_container_by_source_mapping( |
235 | 236 | query_container,source_mapping |
236 | 237 | ) |
| 238 | +ifreturn_only_first_query_ctx_var.get()isTrue: |
| 239 | +returnfinalized_query |
| 240 | +queries_map[source_mapping.source_id]=finalized_query |
237 | 241 | exceptStrictPlatformExceptionaserr: |
238 | | -ifsource_mapping.source_id!=DEFAULT_MAPPING_NAME: |
239 | | -errors.append(err) |
| 242 | +errors.append(err) |
| 243 | +ifindex!=last_mapping_indexorsource_mapping.source_id==DEFAULT_MAPPING_NAMEorqueries_map: |
240 | 244 | continue |
241 | 245 |
|
242 | | -finalized_query=self._generate_from_tokenized_query_container_by_source_mapping( |
243 | | -query_container,self.mappings.get_source_mapping(DEFAULT_MAPPING_NAME) |
244 | | - ) |
| 246 | +withsuppress(StrictPlatformException): |
| 247 | +finalized_query=self._generate_from_tokenized_query_container_by_source_mapping( |
| 248 | +query_container,self.mappings.get_source_mapping(DEFAULT_MAPPING_NAME) |
| 249 | + ) |
| 250 | +queries_map[source_mapping.source_id]=finalized_query |
245 | 251 |
|
246 | | -ifreturn_only_first_query_ctx_var.get()isTrue: |
247 | | -returnfinalized_query |
248 | | -queries_map[source_mapping.source_id]=finalized_query |
249 | 252 | ifnotqueries_mapanderrors: |
250 | 253 | raiseerrors[0] |
251 | 254 | returnself.finalize(queries_map) |