MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / OnConflictDoUpdate

Class OnConflictDoUpdate

lib/sqlalchemy/dialects/sqlite/dml.py:235–279  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

233
234
235class OnConflictDoUpdate(OnConflictClause):
236 __visit_name__ = "on_conflict_do_update"
237
238 update_values_to_set: Dict[_DMLColumnElement, ColumnElement[Any]]
239 update_whereclause: Optional[ColumnElement[Any]]
240
241 _traverse_internals = OnConflictClause._traverse_internals + [
242 ("update_values_to_set", InternalTraversal.dp_dml_values),
243 ("update_whereclause", InternalTraversal.dp_clauseelement),
244 ]
245
246 def __init__(
247 self,
248 index_elements: _OnConflictIndexElementsT = None,
249 index_where: _OnConflictIndexWhereT = None,
250 set_: _OnConflictSetT = None,
251 where: _OnConflictWhereT = None,
252 ):
253 super().__init__(
254 index_elements=index_elements,
255 index_where=index_where,
256 )
257
258 if isinstance(set_, dict):
259 if not set_:
260 raise ValueError("set parameter dictionary must not be empty")
261 elif isinstance(set_, ColumnCollection):
262 set_ = dict(set_)
263 else:
264 raise ValueError(
265 "set parameter must be a non-empty dictionary "
266 "or a ColumnCollection such as the `.c.` collection "
267 "of a Table object"
268 )
269 self.update_values_to_set = {
270 coercions.expect(roles.DMLColumnRole, k): coercions.expect(
271 roles.ExpressionElementRole, v, type_=NULLTYPE, is_crud=True
272 )
273 for k, v in set_.items()
274 }
275 self.update_whereclause = (
276 coercions.expect(roles.WhereHavingRole, where)
277 if where is not None
278 else None
279 )

Callers 1

on_conflict_do_updateMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected