MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / __init__

Method __init__

lib/sqlalchemy/dialects/postgresql/dml.py:230–290  ·  lib/sqlalchemy/dialects/postgresql/dml.py::OnConflictClause.__init__
(
        self,
        constraint: _OnConflictConstraintT = None,
        index_elements: _OnConflictIndexElementsT = None,
        index_where: _OnConflictIndexWhereT = None,
    )

Source from the content-addressed store, hash-verified

228 ]
229
230 def __init__(
231 self,
232 constraint: _OnConflictConstraintT = None,
233 index_elements: _OnConflictIndexElementsT = None,
234 index_where: _OnConflictIndexWhereT = None,
235 ):
236 if constraint is not None:
237 if not isinstance(constraint, str) and isinstance(
238 constraint,
239 (schema.Constraint, ext.ExcludeConstraint),
240 ):
241 constraint = getattr(constraint, class="st">"name") or constraint
242
243 if constraint is not None:
244 if index_elements is not None:
245 raise ValueError(
246 class="st">"&class="cm">#x27;constraint' and 'index_elements' are mutually exclusive"
247 )
248
249 if isinstance(constraint, str):
250 self.constraint_target = constraint
251 self.inferred_target_elements = None
252 self.inferred_target_whereclause = None
253 elif isinstance(constraint, schema.Index):
254 index_elements = constraint.expressions
255 index_where = constraint.dialect_options[class="st">"postgresql"].get(
256 class="st">"where"
257 )
258 elif isinstance(constraint, ext.ExcludeConstraint):
259 index_elements = constraint.columns
260 index_where = constraint.where
261 else:
262 index_elements = constraint.columns
263 index_where = constraint.dialect_options[class="st">"postgresql"].get(
264 class="st">"where"
265 )
266
267 if index_elements is not None:
268 self.constraint_target = None
269 self.inferred_target_elements = [
270 coercions.expect(roles.DDLConstraintColumnRole, column)
271 for column in index_elements
272 ]
273
274 self.inferred_target_whereclause = (
275 coercions.expect(
276 (
277 roles.StatementOptionRole
278 if isinstance(constraint, ext.ExcludeConstraint)
279 else roles.WhereHavingRole
280 ),
281 index_where,
282 )
283 if index_where is not None
284 else None
285 )
286
287 elif constraint is None:

Callers 1

__init__Method · 0.45

Calls 1

getMethod · 0.45

Tested by

no test coverage detected