From c978054133bbbd6703bed798c7f7f5a22c13bd46 Mon Sep 17 00:00:00 2001 From: Iaroslav Zeigerman Date: Thu, 14 Aug 2025 15:46:11 -0700 Subject: [PATCH] Fix: Support aliases for the password field in dbt target config --- sqlmesh/dbt/target.py | 6 +++--- tests/dbt/test_config.py | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) diff --git a/sqlmesh/dbt/target.py b/sqlmesh/dbt/target.py index 94f4c98894..30a8f35c50 100644 --- a/sqlmesh/dbt/target.py +++ b/sqlmesh/dbt/target.py @@ -5,7 +5,7 @@ from pathlib import Path from dbt.adapters.base import BaseRelation, Column -from pydantic import Field +from pydantic import Field, AliasChoices from sqlmesh.core.console import get_console from sqlmesh.core.config.connection import ( @@ -329,7 +329,7 @@ class PostgresConfig(TargetConfig): type: t.Literal["postgres"] = "postgres" host: str user: str - password: str + password: str = Field(validation_alias=AliasChoices("pass", "password")) port: int dbname: str keepalives_idle: t.Optional[int] = None @@ -417,7 +417,7 @@ class RedshiftConfig(TargetConfig): type: t.Literal["redshift"] = "redshift" host: str user: str - password: str + password: str = Field(validation_alias=AliasChoices("pass", "password")) port: int dbname: str connect_timeout: t.Optional[int] = None diff --git a/tests/dbt/test_config.py b/tests/dbt/test_config.py index eaa2fe94ad..f34a1c6c74 100644 --- a/tests/dbt/test_config.py +++ b/tests/dbt/test_config.py @@ -650,6 +650,28 @@ def test_postgres_config(): "outputs", "dev", ) + # 'pass' field instead of 'password' + _test_warehouse_config( + """ + dbt-postgres: + target: dev + outputs: + dev: + type: postgres + host: postgres + user: postgres + pass: postgres + port: 5432 + dbname: postgres + schema: demo + threads: 3 + keepalives_idle: 0 + """, + PostgresConfig, + "dbt-postgres", + "outputs", + "dev", + ) def test_redshift_config(): @@ -674,6 +696,28 @@ def test_redshift_config(): "outputs", "dev", ) + # 'pass' field instead of 'password' + _test_warehouse_config( + """ + dbt-redshift: + target: dev + outputs: + dev: + type: redshift + host: hostname.region.redshift.amazonaws.com + user: username + pass: password1 + port: 5439 + dbname: analytics + schema: analytics + threads: 4 + ra3_node: false + """, + RedshiftConfig, + "dbt-redshift", + "outputs", + "dev", + ) def test_databricks_config():