MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / ordered_values

Method ordered_values

lib/sqlalchemy/sql/dml.py:1570–1602  ·  view source on GitHub ↗

Specify the VALUES clause of this UPDATE statement with an explicit parameter ordering that will be maintained in the SET clause of the resulting UPDATE statement. E.g.:: stmt = table.update().ordered_values(("name", "ed"), ("ident", "foo")) .. seealso:

(self, *args: Tuple[_DMLColumnArgument, Any])

Source from the content-addressed store, hash-verified

1568
1569 @_generative
1570 def ordered_values(self, *args: Tuple[_DMLColumnArgument, Any]) -> Self:
1571 """Specify the VALUES clause of this UPDATE statement with an explicit
1572 parameter ordering that will be maintained in the SET clause of the
1573 resulting UPDATE statement.
1574
1575 E.g.::
1576
1577 stmt = table.update().ordered_values(("name", "ed"), ("ident", "foo"))
1578
1579 .. seealso::
1580
1581 :ref:`tutorial_parameter_ordered_updates` - full example of the
1582 :meth:`_expression.Update.ordered_values` method.
1583
1584 .. versionchanged:: 1.4 The :meth:`_expression.Update.ordered_values`
1585 method
1586 supersedes the
1587 :paramref:`_expression.update.preserve_parameter_order`
1588 parameter, which will be removed in SQLAlchemy 2.0.
1589
1590 """ # noqa: E501
1591 if self._values:
1592 raise exc.ArgumentError(
1593 "This statement already has values present"
1594 )
1595 elif self._ordered_values:
1596 raise exc.ArgumentError(
1597 "This statement already has ordered values present"
1598 )
1599
1600 kv_generator = DMLState.get_plugin_class(self)._get_crud_kv_pairs
1601 self._ordered_values = kv_generator(self, args, True)
1602 return self
1603
1604 @_generative
1605 def inline(self) -> Self:

Calls 1

get_plugin_classMethod · 0.45