From 704448e650de881cddc20dcd1af644a73c2a7895 Mon Sep 17 00:00:00 2001 From: "Michael J. Sullivan" Date: Tue, 30 Jul 2024 17:39:27 -0700 Subject: [PATCH] Tweak how bootstrap_mode is threaded into delta contests (#7610) Currently it is semi-ignored in a weird way. --- edb/server/bootstrap.py | 8 ++++++-- edb/server/compiler/compiler.py | 2 ++ edb/server/compiler/ddl.py | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/edb/server/bootstrap.py b/edb/server/bootstrap.py index 3beb7033764..49170dc1946 100644 --- a/edb/server/bootstrap.py +++ b/edb/server/bootstrap.py @@ -596,6 +596,7 @@ def compile_bootstrap_script( schema: s_schema.Schema, eql: str, *, + bootstrap_mode: bool = True, expected_cardinality_one: bool = False, output_format: edbcompiler.OutputFormat = edbcompiler.OutputFormat.JSON, ) -> Tuple[s_schema.Schema, str]: @@ -606,7 +607,8 @@ def compile_bootstrap_script( expected_cardinality_one=expected_cardinality_one, json_parameters=True, output_format=output_format, - bootstrap_mode=True, + bootstrap_mode=bootstrap_mode, + log_ddl_as_migrations=False, ) return edbcompiler.compile_edgeql_script(ctx, eql) @@ -1790,7 +1792,9 @@ async def _init_defaults(schema, compiler, conn): CREATE MODULE default; ''' - schema, sql = compile_bootstrap_script(compiler, schema, script) + schema, sql = compile_bootstrap_script( + compiler, schema, script, bootstrap_mode=False + ) await _execute(conn, sql) return schema diff --git a/edb/server/compiler/compiler.py b/edb/server/compiler/compiler.py index 67e8cdcc3d9..0e9f7c2efd3 100644 --- a/edb/server/compiler/compiler.py +++ b/edb/server/compiler/compiler.py @@ -287,6 +287,7 @@ def new_compiler_context( internal_schema_mode: bool = False, protocol_version: defines.ProtocolVersion = defines.CURRENT_PROTOCOL, backend_runtime_params: Optional[pg_params.BackendRuntimeParams] = None, + log_ddl_as_migrations: bool = True, ) -> CompileContext: """Create and return an ad-hoc compiler context.""" @@ -313,6 +314,7 @@ def new_compiler_context( backend_runtime_params=( backend_runtime_params or pg_params.get_default_runtime_params() ), + log_ddl_as_migrations=log_ddl_as_migrations, ) return ctx diff --git a/edb/server/compiler/ddl.py b/edb/server/compiler/ddl.py index 2a95d38422e..64519dfcf0e 100644 --- a/edb/server/compiler/ddl.py +++ b/edb/server/compiler/ddl.py @@ -282,7 +282,6 @@ def _new_delta_context( ) -> s_delta.CommandContext: return s_delta.CommandContext( backend_runtime_params=ctx.compiler_state.backend_runtime_params, - stdmode=ctx.bootstrap_mode, internal_schema_mode=ctx.internal_schema_mode, **(_get_delta_context_args(ctx) if args is None else args), ) @@ -291,6 +290,7 @@ def _new_delta_context( def _get_delta_context_args(ctx: compiler.CompileContext) -> dict[str, Any]: """Get the args needed for delta_and_schema_from_ddl""" return dict( + stdmode=ctx.bootstrap_mode, testmode=compiler._get_config_val(ctx, '__internal_testmode'), allow_dml_in_functions=( compiler._get_config_val(ctx, 'allow_dml_in_functions')