options.py 978 B

123456789101112131415161718192021222324252627282930313233
  1. from typing import Dict, List, Optional, Union
  2. from psqlextra.types import PostgresPartitioningMethod, SQLWithParams
  3. class PostgresPartitionedModelOptions:
  4. """Container for :see:PostgresPartitionedModel options.
  5. This is where attributes copied from the model's `PartitioningMeta`
  6. are held.
  7. """
  8. def __init__(self, method: PostgresPartitioningMethod, key: List[str]):
  9. self.method = method
  10. self.key = key
  11. self.original_attrs: Dict[
  12. str, Union[PostgresPartitioningMethod, List[str]]
  13. ] = dict(method=method, key=key)
  14. class PostgresViewOptions:
  15. """Container for :see:PostgresView and :see:PostgresMaterializedView
  16. options.
  17. This is where attributes copied from the model's `ViewMeta` are
  18. held.
  19. """
  20. def __init__(self, query: Optional[SQLWithParams]):
  21. self.query = query
  22. self.original_attrs: Dict[str, Optional[SQLWithParams]] = dict(
  23. query=self.query
  24. )