def _descend( cmd: sd.Command, *, classlayout: Dict[Type[so.Object], sr_struct.SchemaTypeLayout], schema: s_schema.Schema, context: sd.CommandContext, blocks: List[Tuple[str, Dict[str, Any]]], is_internal_reflection: bool, stdmode: bool, prerequisites: bool = False, ) -> None: if prerequisites: commands = cmd.get_prerequisites() else: commands = cmd.get_subcommands(include_prerequisites=False) ctxcls = cmd.get_context_class() if ctxcls is not None: if ( issubclass(ctxcls, sd.ObjectCommandContext) and isinstance(cmd, sd.ObjectCommand) ): objctxcls = cast( Type[sd.ObjectCommandContext[so.Object]], ctxcls, ) ctx = objctxcls(schema=schema, op=cmd, scls=sd._dummy_object) else: # I could not find a way to convince mypy here. ctx = ctxcls(schema=schema, op=cmd) # type: ignore with context(ctx): for subcmd in commands: if isinstance(subcmd, sd.AlterObjectProperty): continue write_meta( subcmd, classlayout=classlayout, schema=schema, context=context, blocks=blocks, is_internal_reflection=is_internal_reflection, stdmode=stdmode, ) else: for subcmd in commands: if isinstance(subcmd, sd.AlterObjectProperty): continue write_meta( subcmd, classlayout=classlayout, schema=schema, context=context, blocks=blocks, is_internal_reflection=is_internal_reflection, stdmode=stdmode, )
def _run_ddl( ddl_text: str, *, schema: s_schema.Schema, delta: sd.Command, ) -> s_schema.Schema: schema, cmd = s_ddl.apply_ddl_script_ex( ddl_text, schema=schema, stdmode=True, ) delta.update(cmd.get_subcommands()) return schema