Repository: litestar-org/litestar

Issue:
StaticFilesConfig and virtual directories
I'm trying to write a ``FileSystemProtocol`` to load files from the package data using [importlib_resources](https://importlib-resources.readthedocs.io/en/latest/using.html#). But because ``directories`` is defined as ``DirectoryPath``, pydantic checks if the given directories exist in the local filesystem. 

This is not generally true, especially in any kind of virtual filesystem (e.g. a zipped package). I think this condition should be relaxed to support virtual filesystems.

https://github.com/starlite-api/starlite/blob/9bb6dcd57c10a591377cf8e3a537e9292566d5b9/starlite/config/static_files.py#L32


Discussion:
I agree. Do you want to submit a PR?

Resolving patch:
diff --git a/litestar/contrib/sqlalchemy/dto.py b/litestar/contrib/sqlalchemy/dto.py
--- a/litestar/contrib/sqlalchemy/dto.py
+++ b/litestar/contrib/sqlalchemy/dto.py
@@ -216,6 +216,11 @@ def _detect_defaults(elem: ElementType) -> tuple[Any, Any]:
             def default_factory(d: Any = sqla_default) -> Any:
                 return d.arg({})
 
+        elif sqla_default.is_sequence:
+            # SQLAlchemy sequences represent server side defaults
+            # so we cannot infer a reasonable default value for
+            # them on the client side
+            pass
         else:
             raise ValueError("Unexpected default type")
     else:


Test patch:
diff --git a/tests/unit/test_contrib/test_sqlalchemy/test_dto_integration.py b/tests/unit/test_contrib/test_sqlalchemy/test_dto_integration.py
--- a/tests/unit/test_contrib/test_sqlalchemy/test_dto_integration.py
+++ b/tests/unit/test_contrib/test_sqlalchemy/test_dto_integration.py
@@ -329,3 +329,45 @@ def get_handler(data: Circle) -> Circle:
         response = client.post("/", json={"radius": 5})
         assert response.json() == {"id": 1, "radius": 5}
         assert module.DIAMETER == 10
+
+
+async def test_field_with_sequence_default_value(create_module: Callable[[str], ModuleType]) -> None:
+    module = create_module(
+        """
+from sqlalchemy import create_engine, Column, Integer, Sequence
+from sqlalchemy.orm import DeclarativeBase, Mapped, sessionmaker
+
+from litestar import Litestar, post
+from litestar.contrib.sqlalchemy.dto import SQLAlchemyDTO
+from litestar.dto.factory import DTOConfig
+
+engine = create_engine('sqlite:///:memory:', echo=True)
+Session = sessionmaker(bind=engine, expire_on_commit=False)
+
+class Base(DeclarativeBase):
+    pass
+
+class Model(Base):
+    __tablename__ = "model"
+    id: Mapped[int] = Column(Integer, Sequence('model_id_seq', optional=False), primary_key=True)
+    val: Mapped[str]
+
+class ModelCreateDTO(SQLAlchemyDTO[Model]):
+    config = DTOConfig(exclude={"id"})
+
+ModelReturnDTO = SQLAlchemyDTO[Model]
+
+@post("/", dto=ModelCreateDTO, return_dto=ModelReturnDTO, sync_to_thread=False)
+def post_handler(data: Model) -> Model:
+    Base.metadata.create_all(engine)
+
+    with Session() as session:
+        session.add(data)
+        session.commit()
+
+    return data
+    """
+    )
+    with create_test_client(route_handlers=[module.post_handler], debug=True) as client:
+        response = client.post("/", json={"val": "value"})
+        assert response.json() == {"id": 1, "val": "value"}