"""Tests Mapped covariance."""\r
\r
+from datetime import datetime\r
from typing import Protocol\r
+from typing import Union\r
\r
from sqlalchemy import ForeignKey\r
+from sqlalchemy import func\r
+from sqlalchemy import Nullable\r
from sqlalchemy.orm import DeclarativeBase\r
from sqlalchemy.orm import Mapped\r
from sqlalchemy.orm import mapped_column\r
from sqlalchemy.orm import relationship\r
-\r
+from sqlalchemy.sql.elements import SQLCoreOperations\r
\r
# Protocols\r
\r
\r
\r
assert get_parent_name(Child(parent=Parent(name="foo"))) == "foo"\r
+\r
+# other test\r
+\r
+\r
+class NullableModel(DeclarativeBase):\r
+ not_null: Mapped[datetime]\r
+ nullable: Mapped[Union[datetime, None]]\r
+\r
+\r
+test = NullableModel()\r
+test.not_null = func.now()\r
+test.nullable = func.now()\r
+\r
+nullable_now: SQLCoreOperations[Union[datetime, None]] = Nullable(func.now())\r
+test.nullable = Nullable(func.now())\r