summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/attributes.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2022-12-27 17:20:07 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2022-12-27 17:22:44 -0500
commit5cf6b6688ba9825fdba21478bc3c70fc7c4a78f5 (patch)
treeebbc4f8ce403b75cff5f8f1527f1e415d847c2f5 /lib/sqlalchemy/orm/attributes.py
parent6eceb939744e000e627edeabe2da4694fa193eff (diff)
downloadsqlalchemy-5cf6b6688ba9825fdba21478bc3c70fc7c4a78f5.tar.gz
remove errant NO_KEY symbol
the symbol from base is used in the event API and is passed along from attributes here. for the additional use where it's an exception case for attribute name as passed by hybrid, use a different symbol name. Change-Id: I8c5c0e71d19185ebec64f2fcbfe1e9be74e54287
Diffstat (limited to 'lib/sqlalchemy/orm/attributes.py')
-rw-r--r--lib/sqlalchemy/orm/attributes.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/sqlalchemy/orm/attributes.py b/lib/sqlalchemy/orm/attributes.py
index 5e6852cbf..65d6970a9 100644
--- a/lib/sqlalchemy/orm/attributes.py
+++ b/lib/sqlalchemy/orm/attributes.py
@@ -55,6 +55,7 @@ from .base import Mapped as Mapped # noqa
from .base import NEVER_SET # noqa
from .base import NO_AUTOFLUSH
from .base import NO_CHANGE # noqa
+from .base import NO_KEY
from .base import NO_RAISE
from .base import NO_VALUE
from .base import NON_PERSISTENT_OK # noqa
@@ -115,20 +116,16 @@ if TYPE_CHECKING:
_T = TypeVar("_T")
-class NoKey(str):
- pass
-
-
_AllPendingType = Sequence[
Tuple[Optional["InstanceState[Any]"], Optional[object]]
]
-NO_KEY = NoKey("no name")
-
SelfQueryableAttribute = TypeVar(
"SelfQueryableAttribute", bound="QueryableAttribute[Any]"
)
+_UNKNOWN_ATTR_KEY = object()
+
@inspection._self_inspects
class QueryableAttribute(
@@ -327,7 +324,12 @@ class QueryableAttribute(
def _memoized_attr_expression(self) -> ColumnElement[_T]:
annotations: _AnnotationDict
- if self.key is NO_KEY:
+ # applies only to Proxy() as used by hybrid.
+ # currently is an exception to typing rather than feeding through
+ # non-string keys.
+ # ideally Proxy() would have a separate set of methods to deal
+ # with this case.
+ if self.key is _UNKNOWN_ATTR_KEY: # type: ignore[comparison-overlap]
annotations = {"entity_namespace": self._entity_namespace}
else:
annotations = {