From 3347166ef7463d8dd06b653472be2f94b73c3820 Mon Sep 17 00:00:00 2001 From: Loic Quertenmont Date: Sat, 4 Mar 2023 07:24:57 +0100 Subject: [PATCH 1/3] feat: support for composite/sub partitioning --- psqlextra/backend/schema.py | 192 ++++++++++++------ .../management/commands/pgmakemigrations.py | 1 - psqlextra/models/options.py | 20 +- psqlextra/models/partitioned.py | 12 +- psqlextra/partitioning/config.py | 2 + psqlextra/partitioning/manager.py | 64 ++++-- psqlextra/partitioning/partition.py | 13 +- psqlextra/partitioning/plan.py | 4 +- psqlextra/partitioning/range_partition.py | 6 +- 9 files changed, 213 insertions(+), 101 deletions(-) diff --git a/psqlextra/backend/schema.py b/psqlextra/backend/schema.py index b59ed617..8385f2f1 100644 --- a/psqlextra/backend/schema.py +++ b/psqlextra/backend/schema.py @@ -1,23 +1,15 @@ -from typing import Any, List, Optional +from typing import Any, List, Optional, Tuple from unittest import mock -from django.core.exceptions import ( - FieldDoesNotExist, - ImproperlyConfigured, - SuspiciousOperation, -) +from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured, SuspiciousOperation from django.db import transaction from django.db.models import Field, Model - from psqlextra.type_assertions import is_sql_with_params from psqlextra.types import PostgresPartitioningMethod from . import base_impl from .introspection import PostgresIntrospection -from .side_effects import ( - HStoreRequiredSchemaEditorSideEffect, - HStoreUniqueSchemaEditorSideEffect, -) +from .side_effects import HStoreRequiredSchemaEditorSideEffect, HStoreUniqueSchemaEditorSideEffect class PostgresSchemaEditor(base_impl.schema_editor()): @@ -28,23 +20,15 @@ class PostgresSchemaEditor(base_impl.schema_editor()): sql_create_view = "CREATE VIEW %s AS (%s)" sql_replace_view = "CREATE OR REPLACE VIEW %s AS (%s)" sql_drop_view = "DROP VIEW IF EXISTS %s" - sql_create_materialized_view = ( - "CREATE MATERIALIZED VIEW %s AS (%s) WITH DATA" - ) + sql_create_materialized_view = "CREATE MATERIALIZED VIEW %s AS (%s) WITH DATA" sql_drop_materialized_view = "DROP MATERIALIZED VIEW %s" sql_refresh_materialized_view = "REFRESH MATERIALIZED VIEW %s" - sql_refresh_materialized_view_concurrently = ( - "REFRESH MATERIALIZED VIEW CONCURRENTLY %s" - ) + sql_refresh_materialized_view_concurrently = "REFRESH MATERIALIZED VIEW CONCURRENTLY %s" sql_partition_by = " PARTITION BY %s (%s)" sql_add_default_partition = "CREATE TABLE %s PARTITION OF %s DEFAULT" sql_add_hash_partition = "CREATE TABLE %s PARTITION OF %s FOR VALUES WITH (MODULUS %s, REMAINDER %s)" - sql_add_range_partition = ( - "CREATE TABLE %s PARTITION OF %s FOR VALUES FROM (%s) TO (%s)" - ) - sql_add_list_partition = ( - "CREATE TABLE %s PARTITION OF %s FOR VALUES IN (%s)" - ) + sql_add_range_partition = "CREATE TABLE %s PARTITION OF %s FOR VALUES FROM (%s) TO (%s)" + sql_add_list_partition = "CREATE TABLE %s PARTITION OF %s FOR VALUES IN (%s)" sql_delete_partition = "DROP TABLE %s" sql_table_comment = "COMMENT ON TABLE %s IS %s" @@ -63,6 +47,13 @@ def __init__(self, connection, collect_sql=False, atomic=True): self.deferred_sql = [] self.introspection = PostgresIntrospection(self.connection) + def execute(self, sql, params=()): + """execute query""" + # print(sql, params) + # if not raw: + # return super().execute(sql, params) + return super().execute(sql, params) + def create_model(self, model: Model) -> None: """Creates a new model.""" @@ -79,16 +70,10 @@ def delete_model(self, model: Model) -> None: super().delete_model(model) - def refresh_materialized_view_model( - self, model: Model, concurrently: bool = False - ) -> None: + def refresh_materialized_view_model(self, model: Model, concurrently: bool = False) -> None: """Refreshes a materialized view.""" - sql_template = ( - self.sql_refresh_materialized_view_concurrently - if concurrently - else self.sql_refresh_materialized_view - ) + sql_template = self.sql_refresh_materialized_view_concurrently if concurrently else self.sql_refresh_materialized_view sql = sql_template % self.quote_name(model._meta.db_table) self.execute(sql) @@ -131,9 +116,7 @@ def replace_materialized_view_model(self, model: Model) -> None: """ with self.connection.cursor() as cursor: - constraints = self.introspection.get_constraints( - cursor, model._meta.db_table - ) + constraints = self.introspection.get_constraints(cursor, model._meta.db_table) with transaction.atomic(): self.delete_materialized_view_model(model) @@ -151,9 +134,7 @@ def replace_materialized_view_model(self, model: Model) -> None: def delete_materialized_view_model(self, model: Model) -> None: """Deletes a materialized view model.""" - sql = self.sql_drop_materialized_view % self.quote_name( - model._meta.db_table - ) + sql = self.sql_drop_materialized_view % self.quote_name(model._meta.db_table) self.execute(sql) def create_partitioned_model(self, model: Model) -> None: @@ -165,19 +146,19 @@ def create_partitioned_model(self, model: Model) -> None: # table creations.. sql, params = self._extract_sql(self.create_model, model) - partitioning_key_sql = ", ".join( - self.quote_name(field_name) for field_name in meta.key - ) + partkeys = meta.key + getattr(meta, "subkey", []) + primary_key_sql = ", ".join(self.quote_name(field_name) for field_name in partkeys) + partitioning_key_sql = ", ".join(self.quote_name(field_name) for field_name in meta.key) # create a composite key that includes the partitioning key sql = sql.replace(" PRIMARY KEY", "") - if model._meta.pk.name not in meta.key: + if model._meta.pk.name not in partkeys: sql = sql[:-1] + ", PRIMARY KEY (%s, %s))" % ( self.quote_name(model._meta.pk.name), - partitioning_key_sql, + primary_key_sql, ) else: - sql = sql[:-1] + ", PRIMARY KEY (%s))" % (partitioning_key_sql,) + sql = sql[:-1] + ", PRIMARY KEY (%s))" % (primary_key_sql,) # extend the standard CREATE TABLE statement with # 'PARTITION BY ...' @@ -200,6 +181,8 @@ def add_range_partition( from_values: Any, to_values: Any, comment: Optional[str] = None, + partition_by: Optional[Tuple[str, List[str]]] = None, + parent_partition_name: Optional[str] = None, ) -> None: """Creates a new range partition for the specified partitioned model. @@ -224,6 +207,12 @@ def add_range_partition( comment: Optionally, a comment to add on this partition table. + + partition_by: + Optionally, a tuple of submethod, subkey list that is used to subpartition this table + + parent_partition_name: + Optionnally, for subpartitions, the name of the parent partition """ # asserts the model is a model set up for partitioning @@ -231,25 +220,41 @@ def add_range_partition( table_name = self.create_partition_table_name(model, name) + parent_table_name = model._meta.db_table + if parent_partition_name: + parent_table_name += "_" + parent_partition_name + sql = self.sql_add_range_partition % ( self.quote_name(table_name), - self.quote_name(model._meta.db_table), + self.quote_name(parent_table_name), "%s", "%s", ) + if partition_by: + sql += self.sql_partition_by % ( + partition_by[0].upper(), + ", ".join(self.quote_name(field_name) for field_name in partition_by[1]), + ) + + print("RANGE", sql) with transaction.atomic(): self.execute(sql, (from_values, to_values)) if comment: self.set_comment_on_table(table_name, comment) + if partition_by: + self.add_default_partition(model, name + "_default", comment, parent_partition_name=name) + def add_list_partition( self, model: Model, name: str, values: List[Any], comment: Optional[str] = None, + partition_by: Optional[Tuple[str, List[str]]] = None, + parent_partition_name: Optional[str] = None, ) -> None: """Creates a new list partition for the specified partitioned model. @@ -268,6 +273,12 @@ def add_list_partition( comment: Optionally, a comment to add on this partition table. + + partition_by: + Optionally, a tuple of submethod, subkey list that is used to subpartition this table + + parent_partition_name: + Optionnally, for subpartitions, the name of the parent partition """ # asserts the model is a model set up for partitioning @@ -275,18 +286,32 @@ def add_list_partition( table_name = self.create_partition_table_name(model, name) + parent_table_name = model._meta.db_table + if parent_partition_name: + parent_table_name += "_" + parent_partition_name + sql = self.sql_add_list_partition % ( self.quote_name(table_name), - self.quote_name(model._meta.db_table), + self.quote_name(parent_table_name), ",".join(["%s" for _ in range(len(values))]), ) + if partition_by: + sql += self.sql_partition_by % ( + partition_by[0].upper(), + ", ".join(self.quote_name(field_name) for field_name in partition_by[1]), + ) + + print("LIST", sql) with transaction.atomic(): self.execute(sql, values) if comment: self.set_comment_on_table(table_name, comment) + if partition_by: + self.add_default_partition(model, name + "_default", comment, parent_partition_name=table_name) + def add_hash_partition( self, model: Model, @@ -294,6 +319,8 @@ def add_hash_partition( modulus: int, remainder: int, comment: Optional[str] = None, + partition_by: Optional[Tuple[str, List[str]]] = None, + parent_partition_name: Optional[str] = None, ) -> None: """Creates a new hash partition for the specified partitioned model. @@ -313,6 +340,12 @@ def add_hash_partition( comment: Optionally, a comment to add on this partition table. + + partition_by: + Optionally, a tuple of submethod, subkey list that is used to subpartition this table + + parent_partition_name: + Optionnally, for subpartitions, the name of the parent partition """ # asserts the model is a model set up for partitioning @@ -320,21 +353,34 @@ def add_hash_partition( table_name = self.create_partition_table_name(model, name) + parent_table_name = model._meta.db_table + if parent_partition_name: + parent_table_name += "_" + parent_partition_name + sql = self.sql_add_hash_partition % ( self.quote_name(table_name), - self.quote_name(model._meta.db_table), + self.quote_name(parent_table_name), "%s", "%s", ) + if partition_by: + sql += self.sql_partition_by % ( + partition_by[0].upper(), + ", ".join(self.quote_name(field_name) for field_name in partition_by[1]), + ) + with transaction.atomic(): self.execute(sql, (modulus, remainder)) if comment: self.set_comment_on_table(table_name, comment) + if partition_by: + self.add_default_partition(model, name + "_default", comment, parent_partition_name=table_name) + def add_default_partition( - self, model: Model, name: str, comment: Optional[str] = None + self, model: Model, name: str, comment: Optional[str] = None, parent_partition_name: Optional[str] = None ) -> None: """Creates a new default partition for the specified partitioned model. @@ -352,6 +398,9 @@ def add_default_partition( comment: Optionally, a comment to add on this partition table. + + parent_partition_name: + Optionnally, for subpartitions, the name of the parent partition """ # asserts the model is a model set up for partitioning @@ -359,11 +408,16 @@ def add_default_partition( table_name = self.create_partition_table_name(model, name) + parent_table_name = model._meta.db_table + if parent_partition_name: + parent_table_name += "_" + parent_partition_name + sql = self.sql_add_default_partition % ( self.quote_name(table_name), - self.quote_name(model._meta.db_table), + self.quote_name(parent_table_name), ) + print("DEFAULT", sql) with transaction.atomic(): self.execute(sql) @@ -373,14 +427,10 @@ def add_default_partition( def delete_partition(self, model: Model, name: str) -> None: """Deletes the partition with the specified name.""" - sql = self.sql_delete_partition % self.quote_name( - self.create_partition_table_name(model, name) - ) + sql = self.sql_delete_partition % self.quote_name(self.create_partition_table_name(model, name)) self.execute(sql) - def alter_db_table( - self, model: Model, old_db_table: str, new_db_table: str - ) -> None: + def alter_db_table(self, model: Model, old_db_table: str, new_db_table: str) -> None: """Alters a table/model.""" super().alter_db_table(model, old_db_table, new_db_table) @@ -461,10 +511,7 @@ def _view_properties_for_model(model: Model): meta = getattr(model, "_view_meta", None) if not meta: raise ImproperlyConfigured( - ( - "Model '%s' is not properly configured to be a view." - " Create the `ViewMeta` class as a child of '%s'." - ) + ("Model '%s' is not properly configured to be a view." " Create the `ViewMeta` class as a child of '%s'.") % (model.__name__, model.__name__) ) @@ -493,10 +540,7 @@ def _partitioning_properties_for_model(model: Model): meta = getattr(model, "_partitioning_meta", None) if not meta: raise ImproperlyConfigured( - ( - "Model '%s' is not properly configured to be partitioned." - " Create the `PartitioningMeta` class as a child of '%s'." - ) + ("Model '%s' is not properly configured to be partitioned." " Create the `PartitioningMeta` class as a child of '%s'.") % (model.__name__, model.__name__) ) @@ -542,6 +586,30 @@ def _partitioning_properties_for_model(model: Model): % (model.__name__, field_name, meta.key, model.__name__) ) + if getattr(meta, "subkey", None): + if not isinstance(meta.subkey, list): + raise ImproperlyConfigured( + ( + "Model '%s' is not properly configured to be subpartitioned." + " Partitioning subkey should be a list (of field names or values," + " depending on the partitioning method)." + ) + % model.__name__ + ) + + try: + for field_name in meta.subkey: + model._meta.get_field(field_name) + except FieldDoesNotExist: + raise ImproperlyConfigured( + ( + "Model '%s' is not properly configured to be subpartitioned." + " Field '%s' in partitioning subkey %s is not a valid field on" + " '%s'." + ) + % (model.__name__, field_name, meta.subkey, model.__name__) + ) + return meta def create_partition_table_name(self, model: Model, name: str) -> str: diff --git a/psqlextra/management/commands/pgmakemigrations.py b/psqlextra/management/commands/pgmakemigrations.py index cdb7131b..72dcf4c0 100644 --- a/psqlextra/management/commands/pgmakemigrations.py +++ b/psqlextra/management/commands/pgmakemigrations.py @@ -1,5 +1,4 @@ from django.core.management.commands import makemigrations - from psqlextra.backend.migrations import postgres_patched_migrations diff --git a/psqlextra/models/options.py b/psqlextra/models/options.py index 79e82863..e7ca52b0 100644 --- a/psqlextra/models/options.py +++ b/psqlextra/models/options.py @@ -10,12 +10,20 @@ class PostgresPartitionedModelOptions: are held. """ - def __init__(self, method: PostgresPartitioningMethod, key: List[str]): + def __init__( + self, + method: PostgresPartitioningMethod, + key: List[str], + submethod: PostgresPartitioningMethod | None = None, + subkey: List[str] | None = None, + ): self.method = method self.key = key - self.original_attrs: Dict[ - str, Union[PostgresPartitioningMethod, List[str]] - ] = dict(method=method, key=key) + self.submethod = submethod + self.subkey = subkey + self.original_attrs: Dict[str, Union[None, PostgresPartitioningMethod, List[str]]] = dict( + method=method, key=key, submethod=submethod, subkey=subkey + ) class PostgresViewOptions: @@ -28,6 +36,4 @@ class PostgresViewOptions: def __init__(self, query: Optional[SQLWithParams]): self.query = query - self.original_attrs: Dict[str, Optional[SQLWithParams]] = dict( - query=self.query - ) + self.original_attrs: Dict[str, Optional[SQLWithParams]] = dict(query=self.query) diff --git a/psqlextra/models/partitioned.py b/psqlextra/models/partitioned.py index c03f3e93..b34ad75e 100644 --- a/psqlextra/models/partitioned.py +++ b/psqlextra/models/partitioned.py @@ -1,5 +1,4 @@ from django.db.models.base import ModelBase - from psqlextra.types import PostgresPartitioningMethod from .base import PostgresModel @@ -23,18 +22,21 @@ def __new__(cls, name, bases, attrs, **kwargs): method = getattr(meta_class, "method", None) key = getattr(meta_class, "key", None) + submethod = getattr(meta_class, "submethod", None) + subkey = getattr(meta_class, "subkey", None) patitioning_meta = PostgresPartitionedModelOptions( - method=method or cls.default_method, key=key or cls.default_key + method=method or cls.default_method, + key=key or cls.default_key, + subkey=subkey, + submethod=submethod, ) new_class.add_to_class("_partitioning_meta", patitioning_meta) return new_class -class PostgresPartitionedModel( - PostgresModel, metaclass=PostgresPartitionedModelMeta -): +class PostgresPartitionedModel(PostgresModel, metaclass=PostgresPartitionedModelMeta): """Base class for taking advantage of PostgreSQL's 11.x native support for table partitioning.""" diff --git a/psqlextra/partitioning/config.py b/psqlextra/partitioning/config.py index df21c057..e99d0442 100644 --- a/psqlextra/partitioning/config.py +++ b/psqlextra/partitioning/config.py @@ -11,9 +11,11 @@ def __init__( self, model: PostgresPartitionedModel, strategy: PostgresPartitioningStrategy, + substrategy: PostgresPartitioningStrategy | None = None, ) -> None: self.model = model self.strategy = strategy + self.substrategy = substrategy __all__ = ["PostgresPartitioningConfig"] diff --git a/psqlextra/partitioning/manager.py b/psqlextra/partitioning/manager.py index 28aee91e..5d1a5c7d 100644 --- a/psqlextra/partitioning/manager.py +++ b/psqlextra/partitioning/manager.py @@ -1,7 +1,6 @@ from typing import List, Optional, Tuple -from django.db import connections - +from django.db import ConnectionProxy, connections from psqlextra.models import PostgresPartitionedModel from .config import PostgresPartitioningConfig @@ -62,14 +61,10 @@ def plan( return PostgresPartitioningPlan(model_plans) - def find_config_for_model( - self, model: PostgresPartitionedModel - ) -> Optional[PostgresPartitioningConfig]: + def find_config_for_model(self, model: PostgresPartitionedModel) -> Optional[PostgresPartitioningConfig]: """Finds the partitioning config for the specified model.""" - return next( - (config for config in self.configs if config.model == model), None - ) + return next((config for config in self.configs if config.model == model), None) def _plan_for_config( self, @@ -84,19 +79,25 @@ def _plan_for_config( table = self._get_partitioned_table(connection, config.model) model_plan = PostgresModelPartitioningPlan(config) + partition_by: Tuple[str, list[str]] | None = None + + meta = getattr(config.model, "_partitioning_meta", None) + if meta and getattr(meta, "submethod", None): + partition_by = (meta.submethod, meta.subkey) if not skip_create: for partition in config.strategy.to_create(): - if table.partition_by_name(name=partition.name()): - continue + if not table.partition_by_name(name=partition.name()): + partition.partition_by = partition_by + model_plan.creations.append(partition) - model_plan.creations.append(partition) + # create subtables + if partition_by: + self._create_subparition(config, model_plan, partition, connection) if not skip_delete: for partition in config.strategy.to_delete(): - introspected_partition = table.partition_by_name( - name=partition.name() - ) + introspected_partition = table.partition_by_name(name=partition.name()) if not introspected_partition: break @@ -110,12 +111,37 @@ def _plan_for_config( return model_plan + @staticmethod + def _create_subparition( + config: PostgresPartitioningConfig, + model_plan: PostgresModelPartitioningPlan, + parent_partition: PostgresPartition, + connection: ConnectionProxy, + ) -> None: + if not hasattr(config, "substrategy") or not config.substrategy: + raise PostgresPartitioningError( + f"Model {config.model.__name__}, does not define a substrategy in its PostgresPartitioningConfig" + "There must be one to define subpartitioning`?" + ) + + parent_partition_name = "%s_%s" % (config.model._meta.db_table.lower(), parent_partition.name().lower()) + + with connection.cursor() as cursor: + table = connection.introspection.get_partitioned_table(cursor, parent_partition_name) + + for partition in config.substrategy.to_create(): + partition_name = parent_partition.name() + "_" + partition.name() + print(partition_name) + if not table or not table.partition_by_name(name=partition_name): + partition.parent_partition_name = parent_partition.name() + model_plan.creations.append(partition) + + return + @staticmethod def _get_partitioned_table(connection, model: PostgresPartitionedModel): with connection.cursor() as cursor: - table = connection.introspection.get_partitioned_table( - cursor, model._meta.db_table - ) + table = connection.introspection.get_partitioned_table(cursor, model._meta.db_table) if not table: raise PostgresPartitioningError( @@ -132,6 +158,4 @@ def _validate_configs(configs: List[PostgresPartitioningConfig]): models = set([config.model.__name__ for config in configs]) if len(models) != len(configs): - raise PostgresPartitioningError( - "Only one partitioning config per model is allowed" - ) + raise PostgresPartitioningError("Only one partitioning config per model is allowed") diff --git a/psqlextra/partitioning/partition.py b/psqlextra/partitioning/partition.py index ca64bbdc..aab78631 100644 --- a/psqlextra/partitioning/partition.py +++ b/psqlextra/partitioning/partition.py @@ -1,5 +1,5 @@ from abc import abstractmethod -from typing import Optional +from typing import List, Optional, Tuple from psqlextra.backend.schema import PostgresSchemaEditor from psqlextra.models import PostgresPartitionedModel @@ -8,10 +8,19 @@ class PostgresPartition: """Base class for a PostgreSQL table partition.""" + partition_by: Optional[Tuple[str, List[str]]] = None + parent_partition_name: Optional[str] = None + @abstractmethod def name(self) -> str: """Generates/computes the name for this partition.""" + def full_name(self) -> str: + """Concatenate the name with the parent_partition name (if needed)""" + if self.parent_partition_name: + return self.parent_partition_name + "_" + self.name() + return self.name() + @abstractmethod def create( self, @@ -32,7 +41,7 @@ def delete( def deconstruct(self) -> dict: """Deconstructs this partition into a dict of attributes/fields.""" - return {"name": self.name()} + return {"name": self.full_name()} __all__ = ["PostgresPartition"] diff --git a/psqlextra/partitioning/plan.py b/psqlextra/partitioning/plan.py index fdb1eee2..56781207 100644 --- a/psqlextra/partitioning/plan.py +++ b/psqlextra/partitioning/plan.py @@ -51,12 +51,12 @@ def print(self) -> None: print(f"{self.config.model.__name__}:") for partition in self.deletions: - print(" - %s" % partition.name()) + print(" - %s" % partition.full_name()) for key, value in partition.deconstruct().items(): print(f" {key}: {value}") for partition in self.creations: - print(" + %s" % partition.name()) + print(" + %s" % partition.full_name()) for key, value in partition.deconstruct().items(): print(f" {key}: {value}") diff --git a/psqlextra/partitioning/range_partition.py b/psqlextra/partitioning/range_partition.py index b49fe784..28010fec 100644 --- a/psqlextra/partitioning/range_partition.py +++ b/psqlextra/partitioning/range_partition.py @@ -1,4 +1,4 @@ -from typing import Any, Optional +from typing import Any, List, Optional, Tuple from psqlextra.backend.schema import PostgresSchemaEditor from psqlextra.models import PostgresPartitionedModel @@ -29,10 +29,12 @@ def create( ) -> None: schema_editor.add_range_partition( model=model, - name=self.name(), + name=self.full_name(), from_values=self.from_values, to_values=self.to_values, comment=comment, + partition_by=self.partition_by, + parent_partition_name=self.parent_partition_name, ) def delete( From 3d886abb7493df53103b8a3f118acd0b9b917f91 Mon Sep 17 00:00:00 2001 From: Loic Quertenmont Date: Sat, 4 Mar 2023 10:34:40 +0100 Subject: [PATCH 2/3] Update schema.py --- psqlextra/backend/schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/psqlextra/backend/schema.py b/psqlextra/backend/schema.py index 8385f2f1..bfac81c5 100644 --- a/psqlextra/backend/schema.py +++ b/psqlextra/backend/schema.py @@ -146,7 +146,7 @@ def create_partitioned_model(self, model: Model) -> None: # table creations.. sql, params = self._extract_sql(self.create_model, model) - partkeys = meta.key + getattr(meta, "subkey", []) + partkeys = meta.key + (getattr(meta, "subkey", None) or []) primary_key_sql = ", ".join(self.quote_name(field_name) for field_name in partkeys) partitioning_key_sql = ", ".join(self.quote_name(field_name) for field_name in meta.key) From 98ff74a8dd7d769729df19377494da5a25e75d92 Mon Sep 17 00:00:00 2001 From: Loic Quertenmont Date: Sat, 4 Mar 2023 14:16:26 +0100 Subject: [PATCH 3/3] Update schema.py --- psqlextra/backend/schema.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/psqlextra/backend/schema.py b/psqlextra/backend/schema.py index bfac81c5..648b8886 100644 --- a/psqlextra/backend/schema.py +++ b/psqlextra/backend/schema.py @@ -49,9 +49,6 @@ def __init__(self, connection, collect_sql=False, atomic=True): def execute(self, sql, params=()): """execute query""" - # print(sql, params) - # if not raw: - # return super().execute(sql, params) return super().execute(sql, params) def create_model(self, model: Model) -> None: @@ -237,7 +234,6 @@ def add_range_partition( ", ".join(self.quote_name(field_name) for field_name in partition_by[1]), ) - print("RANGE", sql) with transaction.atomic(): self.execute(sql, (from_values, to_values)) @@ -302,7 +298,6 @@ def add_list_partition( ", ".join(self.quote_name(field_name) for field_name in partition_by[1]), ) - print("LIST", sql) with transaction.atomic(): self.execute(sql, values) @@ -417,7 +412,6 @@ def add_default_partition( self.quote_name(parent_table_name), ) - print("DEFAULT", sql) with transaction.atomic(): self.execute(sql)