Skip to content

Commit d9fa47e

Browse files
committed
Gate active non-Dolt write capability consistently
1 parent 53f05ca commit d9fa47e

1 file changed

Lines changed: 23 additions & 4 deletions

File tree

src/openstatspec/sql/capabilities.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,23 @@ def _bound_specification_commit() -> str:
5959
return SPECIFICATION_COMMIT
6060

6161

62+
def _active_driver_eligible(database_url: str, profile_name: str) -> bool:
63+
driver = make_url(database_url).drivername.lower()
64+
required = {
65+
"postgresql": "postgresql+psycopg",
66+
"mysql": "mysql+pymysql",
67+
"mariadb": "mariadb+mariadbconnector",
68+
"dolt": "mysql+pymysql",
69+
}
70+
return (
71+
make_url(database_url).get_backend_name() == "sqlite"
72+
if profile_name == "sqlite"
73+
else driver == required[profile_name]
74+
)
75+
76+
6277
def _dolt_driver_eligible(database_url: str) -> bool:
63-
return make_url(database_url).drivername.lower() == "mysql+pymysql"
78+
return _active_driver_eligible(database_url, "dolt")
6479

6580

6681
def dolt_operational_write_enabled(
@@ -246,9 +261,8 @@ def active_connection(
246261
if profile_name == "dolt" else None
247262
),
248263
"observed": observed,
249-
"driver_eligible": (
250-
_dolt_driver_eligible(database_url)
251-
if profile_name == "dolt" else True
264+
"driver_eligible": _active_driver_eligible(
265+
database_url, profile_name,
252266
),
253267
}
254268

@@ -507,6 +521,11 @@ def _profile(
507521
active, declaration_matched=dolt_declaration is not None,
508522
)
509523
if dolt_envelope and active and active["profile"] == name
524+
else (
525+
bool(active["claimed_supported"])
526+
and bool(active["driver_eligible"])
527+
)
528+
if active and active["profile"] == name
510529
else bool((dolt_status or {}).get("write_enabled"))
511530
if dolt_envelope else True
512531
),

0 commit comments

Comments
 (0)