Skip to content

Commit 09217d1

Browse files
authored
Revert "Fix(postgres): Quote role names if required when running SET ROLE on cursor init" (#3834)
1 parent b7c05b4 commit 09217d1

2 files changed

Lines changed: 1 addition & 25 deletions

File tree

sqlmesh/core/config/connection.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,10 +1197,8 @@ def _cursor_init(self) -> t.Optional[t.Callable[[t.Any], None]]:
11971197
if not self.role:
11981198
return None
11991199

1200-
role_identifier = exp.to_identifier(self.role).sql(dialect="postgres")
1201-
12021200
def init(cursor: t.Any) -> None:
1203-
cursor.execute(f"SET ROLE {role_identifier}")
1201+
cursor.execute(f"SET ROLE {self.role}")
12041202

12051203
return init
12061204

tests/core/test_connection_config.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
import pytest
66
from _pytest.fixtures import FixtureRequest
7-
from pytest_mock import MockerFixture
87

98
from sqlmesh.core.config.connection import (
109
BigQueryConnectionConfig,
@@ -682,27 +681,6 @@ def test_postgres(make_config):
682681
assert config.is_recommended_for_state_sync is True
683682

684683

685-
def test_postgres_cursor_init(make_config, mocker: MockerFixture):
686-
config = make_config(
687-
type="postgres",
688-
host="host",
689-
user="user",
690-
password="password",
691-
port=5432,
692-
database="database",
693-
role="foo-bar",
694-
)
695-
696-
assert isinstance(config, PostgresConnectionConfig)
697-
cursor_init = config._cursor_init
698-
assert cursor_init
699-
700-
cursor_mock = mocker.MagicMock()
701-
cursor_init(cursor_mock)
702-
703-
cursor_mock.execute.assert_called_with('SET ROLE "foo-bar"')
704-
705-
706684
def test_gcp_postgres(make_config):
707685
config = make_config(
708686
type="gcp_postgres",

0 commit comments

Comments
 (0)