1
0
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:
MoonTestUse1
2025-02-09 01:11:49 +06:00
parent ce52f8a23a
commit 0aa3ef8fc2
5827 changed files with 14316 additions and 1906434 deletions

View File

@@ -1,5 +1,5 @@
# orm/mapper.py
# Copyright (C) 2005-2024 the SQLAlchemy authors and contributors
# Copyright (C) 2005-2025 the SQLAlchemy authors and contributors
# <see AUTHORS file>
#
# This module is part of SQLAlchemy and is released under
@@ -296,6 +296,17 @@ class Mapper(
particular primary key value. A "partial primary key" can occur if
one has mapped to an OUTER JOIN, for example.
The :paramref:`.orm.Mapper.allow_partial_pks` parameter also
indicates to the ORM relationship lazy loader, when loading a
many-to-one related object, if a composite primary key that has
partial NULL values should result in an attempt to load from the
database, or if a load attempt is not necessary.
.. versionadded:: 2.0.36 :paramref:`.orm.Mapper.allow_partial_pks`
is consulted by the relationship lazy loader strategy, such that
when set to False, a SELECT for a composite primary key that
has partial NULL values will not be emitted.
:param batch: Defaults to ``True``, indicating that save operations
of multiple entities can be batched together for efficiency.
Setting to False indicates
@@ -318,7 +329,7 @@ class Mapper(
class User(Base):
__table__ = user_table
__mapper_args__ = {'column_prefix':'_'}
__mapper_args__ = {"column_prefix": "_"}
The above mapping will assign the ``user_id``, ``user_name``, and
``password`` columns to attributes named ``_user_id``,
@@ -442,7 +453,7 @@ class Mapper(
mapping of the class to an alternate selectable, for loading
only.
.. seealso::
.. seealso::
:ref:`relationship_aliased_class` - the new pattern that removes
the need for the :paramref:`_orm.Mapper.non_primary` flag.
@@ -534,14 +545,14 @@ class Mapper(
base-most mapped :class:`.Table`::
class Employee(Base):
__tablename__ = 'employee'
__tablename__ = "employee"
id: Mapped[int] = mapped_column(primary_key=True)
discriminator: Mapped[str] = mapped_column(String(50))
__mapper_args__ = {
"polymorphic_on":discriminator,
"polymorphic_identity":"employee"
"polymorphic_on": discriminator,
"polymorphic_identity": "employee",
}
It may also be specified
@@ -550,17 +561,18 @@ class Mapper(
approach::
class Employee(Base):
__tablename__ = 'employee'
__tablename__ = "employee"
id: Mapped[int] = mapped_column(primary_key=True)
discriminator: Mapped[str] = mapped_column(String(50))
__mapper_args__ = {
"polymorphic_on":case(
"polymorphic_on": case(
(discriminator == "EN", "engineer"),
(discriminator == "MA", "manager"),
else_="employee"),
"polymorphic_identity":"employee"
else_="employee",
),
"polymorphic_identity": "employee",
}
It may also refer to any attribute using its string name,
@@ -568,14 +580,14 @@ class Mapper(
configurations::
class Employee(Base):
__tablename__ = 'employee'
__tablename__ = "employee"
id: Mapped[int] = mapped_column(primary_key=True)
discriminator: Mapped[str]
__mapper_args__ = {
"polymorphic_on": "discriminator",
"polymorphic_identity": "employee"
"polymorphic_identity": "employee",
}
When setting ``polymorphic_on`` to reference an
@@ -592,6 +604,7 @@ class Mapper(
from sqlalchemy import event
from sqlalchemy.orm import object_mapper
@event.listens_for(Employee, "init", propagate=True)
def set_identity(instance, *arg, **kw):
mapper = object_mapper(instance)
@@ -3248,14 +3261,9 @@ class Mapper(
The resulting structure is a dictionary of columns mapped
to lists of equivalent columns, e.g.::
{
tablea.col1:
{tableb.col1, tablec.col1},
tablea.col2:
{tabled.col2}
}
{tablea.col1: {tableb.col1, tablec.col1}, tablea.col2: {tabled.col2}}
"""
""" # noqa: E501
result: _EquivalentColumnMap = {}
def visit_binary(binary):
@@ -3728,14 +3736,15 @@ class Mapper(
given::
class A:
...
class A: ...
class B(A):
__mapper_args__ = {"polymorphic_load": "selectin"}
class C(B):
...
class C(B): ...
class D(B):
__mapper_args__ = {"polymorphic_load": "selectin"}
@@ -3805,6 +3814,7 @@ class Mapper(
this subclass as a SELECT with IN.
"""
strategy_options = util.preloaded.orm_strategy_options
assert self.inherits
@@ -3828,7 +3838,7 @@ class Mapper(
classes_to_include.add(m)
m = m.inherits
for prop in self.attrs:
for prop in self.column_attrs + self.relationships:
# skip prop keys that are not instrumented on the mapped class.
# this is primarily the "_sa_polymorphic_on" property that gets
# created for an ad-hoc polymorphic_on SQL expression, issue #8704