1616from sqlmesh .utils .date import TimeLike , now_timestamp
1717from sqlmesh .utils .jinja import JinjaMacroRegistry
1818from sqlmesh .utils .metaprogramming import Executable
19- from sqlmesh .utils .pydantic import PydanticModel , field_validator
19+ from sqlmesh .utils .pydantic import PydanticModel , field_validator , ValidationInfo
2020
2121T = t .TypeVar ("T" , bound = "EnvironmentNamingInfo" )
2222PydanticType = t .TypeVar ("PydanticType" , bound = "PydanticModel" )
@@ -32,30 +32,27 @@ class EnvironmentNamingInfo(PydanticModel):
3232 catalog_name_override: The name of the catalog to use for this environment if an override was provided
3333 normalize_name: Indicates whether the environment's name will be normalized. For example, if it's
3434 `dev`, then it will become `DEV` when targeting Snowflake.
35- gateway_managed_virtual_layer : Determines whether the virtual layer's views are created by the model-specific
35+ gateway_managed : Determines whether the virtual layer's views are created by the model-specific
3636 gateways, otherwise the default gateway is used. Default: False.
3737 """
3838
3939 name : str = c .PROD
4040 suffix_target : EnvironmentSuffixTarget = Field (default = EnvironmentSuffixTarget .SCHEMA )
4141 catalog_name_override : t .Optional [str ] = None
4242 normalize_name : bool = True
43- gateway_managed_virtual_layer : bool = False
43+ gateway_managed : bool = False
4444
4545 @field_validator ("name" , mode = "before" )
4646 @classmethod
4747 def _sanitize_name (cls , v : str ) -> str :
4848 return word_characters_only (v ).lower ()
4949
50- @field_validator ("normalize_name" , mode = "before" )
50+ @field_validator ("normalize_name" , "gateway_managed" , mode = "before" )
5151 @classmethod
52- def _validate_normalize_name (cls , v : t .Any ) -> bool :
53- return True if v is None else bool (v )
54-
55- @field_validator ("gateway_managed_virtual_layer" , mode = "before" )
56- @classmethod
57- def _validate_gateway_managed_virtual_layer (cls , v : t .Any ) -> bool :
58- return False if v is None else bool (v )
52+ def _validate_boolean_field (cls , v : t .Any , info : ValidationInfo ) -> bool :
53+ if v is None :
54+ return info .field_name == "normalize_name"
55+ return bool (v )
5956
6057 @t .overload
6158 @classmethod
@@ -202,7 +199,7 @@ def naming_info(self) -> EnvironmentNamingInfo:
202199 suffix_target = self .suffix_target ,
203200 catalog_name_override = self .catalog_name_override ,
204201 normalize_name = self .normalize_name ,
205- gateway_managed_virtual_layer = self .gateway_managed_virtual_layer ,
202+ gateway_managed = self .gateway_managed ,
206203 )
207204
208205 @property
0 commit comments