mirror of
https://gitlab.com/MoonTestUse1/AdministrationItDepartmens.git
synced 2025-08-14 00:25:46 +02:00
Проверка 09.02.2025
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# sql/dml.py
|
||||
# Copyright (C) 2009-2024 the SQLAlchemy authors and contributors
|
||||
# Copyright (C) 2009-2025 the SQLAlchemy authors and contributors
|
||||
# <see AUTHORS file>
|
||||
#
|
||||
# This module is part of SQLAlchemy and is released under
|
||||
@@ -23,6 +23,7 @@ from typing import NoReturn
|
||||
from typing import Optional
|
||||
from typing import overload
|
||||
from typing import Sequence
|
||||
from typing import Set
|
||||
from typing import Tuple
|
||||
from typing import Type
|
||||
from typing import TYPE_CHECKING
|
||||
@@ -42,6 +43,7 @@ from .base import _from_objects
|
||||
from .base import _generative
|
||||
from .base import _select_iterables
|
||||
from .base import ColumnCollection
|
||||
from .base import ColumnSet
|
||||
from .base import CompileState
|
||||
from .base import DialectKWArgs
|
||||
from .base import Executable
|
||||
@@ -418,10 +420,16 @@ class UpdateBase(
|
||||
is_dml = True
|
||||
|
||||
def _generate_fromclause_column_proxies(
|
||||
self, fromclause: FromClause
|
||||
self,
|
||||
fromclause: FromClause,
|
||||
columns: ColumnCollection[str, KeyedColumnElement[Any]],
|
||||
primary_key: ColumnSet,
|
||||
foreign_keys: Set[KeyedColumnElement[Any]],
|
||||
) -> None:
|
||||
fromclause._columns._populate_separate_keys(
|
||||
col._make_proxy(fromclause)
|
||||
columns._populate_separate_keys(
|
||||
col._make_proxy(
|
||||
fromclause, primary_key=primary_key, foreign_keys=foreign_keys
|
||||
)
|
||||
for col in self._all_selected_columns
|
||||
if is_column_element(col)
|
||||
)
|
||||
@@ -525,11 +533,11 @@ class UpdateBase(
|
||||
|
||||
E.g.::
|
||||
|
||||
stmt = table.insert().values(data='newdata').return_defaults()
|
||||
stmt = table.insert().values(data="newdata").return_defaults()
|
||||
|
||||
result = connection.execute(stmt)
|
||||
|
||||
server_created_at = result.returned_defaults['created_at']
|
||||
server_created_at = result.returned_defaults["created_at"]
|
||||
|
||||
When used against an UPDATE statement
|
||||
:meth:`.UpdateBase.return_defaults` instead looks for columns that
|
||||
@@ -1032,7 +1040,7 @@ class ValuesBase(UpdateBase):
|
||||
|
||||
users.insert().values(name="some name")
|
||||
|
||||
users.update().where(users.c.id==5).values(name="some name")
|
||||
users.update().where(users.c.id == 5).values(name="some name")
|
||||
|
||||
:param \*args: As an alternative to passing key/value parameters,
|
||||
a dictionary, tuple, or list of dictionaries or tuples can be passed
|
||||
@@ -1062,13 +1070,17 @@ class ValuesBase(UpdateBase):
|
||||
this syntax is supported on backends such as SQLite, PostgreSQL,
|
||||
MySQL, but not necessarily others::
|
||||
|
||||
users.insert().values([
|
||||
{"name": "some name"},
|
||||
{"name": "some other name"},
|
||||
{"name": "yet another name"},
|
||||
])
|
||||
users.insert().values(
|
||||
[
|
||||
{"name": "some name"},
|
||||
{"name": "some other name"},
|
||||
{"name": "yet another name"},
|
||||
]
|
||||
)
|
||||
|
||||
The above form would render a multiple VALUES statement similar to::
|
||||
The above form would render a multiple VALUES statement similar to:
|
||||
|
||||
.. sourcecode:: sql
|
||||
|
||||
INSERT INTO users (name) VALUES
|
||||
(:name_1),
|
||||
@@ -1246,7 +1258,7 @@ class Insert(ValuesBase):
|
||||
e.g.::
|
||||
|
||||
sel = select(table1.c.a, table1.c.b).where(table1.c.c > 5)
|
||||
ins = table2.insert().from_select(['a', 'b'], sel)
|
||||
ins = table2.insert().from_select(["a", "b"], sel)
|
||||
|
||||
:param names: a sequence of string column names or
|
||||
:class:`_schema.Column`
|
||||
@@ -1535,9 +1547,7 @@ class Update(DMLWhereBase, ValuesBase):
|
||||
|
||||
E.g.::
|
||||
|
||||
stmt = table.update().ordered_values(
|
||||
("name", "ed"), ("ident", "foo")
|
||||
)
|
||||
stmt = table.update().ordered_values(("name", "ed"), ("ident", "foo"))
|
||||
|
||||
.. seealso::
|
||||
|
||||
@@ -1550,7 +1560,7 @@ class Update(DMLWhereBase, ValuesBase):
|
||||
:paramref:`_expression.update.preserve_parameter_order`
|
||||
parameter, which will be removed in SQLAlchemy 2.0.
|
||||
|
||||
"""
|
||||
""" # noqa: E501
|
||||
if self._values:
|
||||
raise exc.ArgumentError(
|
||||
"This statement already has values present"
|
||||
|
Reference in New Issue
Block a user