Skip to content

Commit 75633b2

Browse files
committed
Add an integration test
1 parent d32ec21 commit 75633b2

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

sqlmesh/core/engine_adapter/postgres.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ def merge(
127127
@cached_property
128128
def server_version(self) -> t.Tuple[int, int]:
129129
"""Lazily fetch and cache major and minor server version"""
130-
server_version, *_ = self.fetchone("SHOW server_version")
131-
match = re.search(r"(\d+)\.(\d+)", server_version)
132-
if match:
133-
return int(match.group(1)), int(match.group(2))
130+
if result := self.fetchone("SHOW server_version"):
131+
server_version, *_ = result
132+
match = re.search(r"(\d+)\.(\d+)", server_version)
133+
if match:
134+
return int(match.group(1)), int(match.group(2))
134135
return 0, 0

tests/core/engine_adapter/integration/test_integration_postgres.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import pytest
33
from pytest import FixtureRequest
44
from sqlmesh.core.engine_adapter import PostgresEngineAdapter
5-
from tests.core.engine_adapter.integration import TestContext
65

76
from tests.core.engine_adapter.integration import (
87
TestContext,
@@ -29,3 +28,8 @@ def engine_adapter(ctx: TestContext) -> PostgresEngineAdapter:
2928
def test_engine_adapter(ctx: TestContext):
3029
assert isinstance(ctx.engine_adapter, PostgresEngineAdapter)
3130
assert ctx.engine_adapter.fetchone("select 1") == (1,)
31+
32+
33+
def test_server_version_psycopg(ctx: TestContext):
34+
assert isinstance(ctx.engine_adapter, PostgresEngineAdapter)
35+
assert ctx.engine_adapter.server_version != (0, 0)

0 commit comments

Comments
 (0)