Skip to content

Commit b9241b0

Browse files
committed
Cover effective profile driver, identifier, and string storage
1 parent c9ff699 commit b9241b0

1 file changed

Lines changed: 56 additions & 0 deletions

File tree

‎tests/test_sql_profiles.py‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,59 @@ def fail_identity(_url, **_kwargs):
489489
)
490490

491491
assert not destination.exists()
492+
493+
def test_effective_profile_preserves_explicit_driver_validation(monkeypatch) -> None:
494+
def unexpected_active_connection(*_args, **_kwargs):
495+
raise AssertionError("active connection must not be probed for a rejected driver")
496+
497+
monkeypatch.setattr(
498+
capabilities, "active_connection", unexpected_active_connection,
499+
)
500+
501+
with pytest.raises(
502+
UnsupportedOperationError,
503+
match=r"PostgreSQL requires an explicit postgresql\+psycopg URL",
504+
):
505+
effective_profile("postgresql+psycopg2://user@host/database")
506+
507+
508+
def test_effective_profile_applies_declared_identifier_limit(monkeypatch) -> None:
509+
active = {
510+
"profile": "postgresql",
511+
"claimed_supported": True,
512+
"server_version": "17.10",
513+
"observed": {},
514+
}
515+
limits = {
516+
"identifier_limit": {"value": 7},
517+
"maximum_source_variables": 10,
518+
"maximum_value_bytes": 100,
519+
"maximum_row_bytes": 200,
520+
"maximum_statement_bytes": 300,
521+
}
522+
monkeypatch.setattr(
523+
capabilities, "active_connection", lambda _url, **_kwargs: active,
524+
)
525+
monkeypatch.setattr(
526+
capabilities, "_profile", lambda *_args, **_kwargs: {
527+
"effective_limits": limits,
528+
},
529+
)
530+
531+
profile, observed = effective_profile(
532+
"postgresql+psycopg://user@host/database",
533+
)
534+
535+
assert observed is active
536+
assert profile.identifier_limit == 7
537+
538+
539+
def test_wide_string_column_uses_effective_dolt_storage() -> None:
540+
table = Table(
541+
"dolt_wide_text",
542+
MetaData(),
543+
Column("value", wide._wide_column_type(DOLT, "string")),
544+
)
545+
546+
ddl = str(CreateTable(table).compile(dialect=mysql.dialect())).upper()
547+
assert "VALUE LONGTEXT" in ddl

0 commit comments

Comments
 (0)