Skip to content

Commit

Permalink
Update to use aliasing that works for pydantic 1.10
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyholcomb committed Oct 25, 2023
1 parent 5c023a6 commit 349c8ff
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions dbt_semantic_interfaces/implementations/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@
class PydanticExportConfig(HashableBaseModel, ProtocolHint[ExportConfig]):
"""Pydantic implementation of ExportConfig.
Note on `schema_name`: `schema` is a BaseModel attribute so we need to alias it here.
Use `schema` for YAML definition & JSON, `schema_name` for object attribute.
Note on `schema_name`: `schema` is an existing BaseModel attribute, so we need to alias it here.
`Field.alias="schema"` enables using the `schema` key in YAML. `Config.allow_population_by_field_name`
enables parsing for both `schema` and `schema_name` when deserializing from JSON.
"""

class Config:
allow_population_by_field_name = True

@override
def _implements_protocol(self) -> ExportConfig:
return self

export_as: ExportDestinationType
schema_name: Optional[str] = Field(serialization_alias="schema", validation_alias="schema_name")
schema_name: Optional[str] = Field(alias="schema", default=None)
alias: Optional[str] = None


Expand Down

0 comments on commit 349c8ff

Please sign in to comment.