From b43db44d387b766abb3f5d959aebec35ea6951b6 Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Wed, 27 Nov 2024 17:03:33 +0100 Subject: [PATCH] database.database:Database.create_view - add ignore parameter --- acacore/database/database.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/acacore/database/database.py b/acacore/database/database.py index d50764d..d93a91b 100644 --- a/acacore/database/database.py +++ b/acacore/database/database.py @@ -152,17 +152,26 @@ def create_table( """ return Table(self.connection, model, name, primary_keys, indices, ignore).create(exist_ok=exist_ok) - def create_view(self, model: Type[_M], name: str, select: str, *, exist_ok: bool = True) -> View[_M]: + def create_view( + self, + model: Type[_M], + name: str, + select: str, + ignore: list[str] | None = None, + *, + exist_ok: bool = True, + ) -> View[_M]: """ Create a view in the database based on a model. :param model: The Pydantic model to create the view for. :param name: The name of the view. :param select: The select SQL expression to use to populate the view. + :param ignore: A list of field names to ignore from the model. :param exist_ok: Whether to ignore any existing view with the same name. :return: A ``View`` instance. """ - return View(self.connection, model, name, select).create(exist_ok=exist_ok) + return View(self.connection, model, name, select, ignore).create(exist_ok=exist_ok) def create_keys_table(self, model: Type[_M], name: str, *, exist_ok: bool = True) -> KeysTable[_M]: """