Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

mssql_python: discrete connection fields are silently ignored when connection_string is set

Chiusa
#788 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
database

Direzione di ricerca

Start in sqlspec/adapters/mssql_python/core.py at build_connection_config, then compare the mssql_python behavior with the arrow_odbc adapter's connection configuration logic and documented precedence. Use the reproduction in the issue to verify that database overrides are no longer silently ignored, and add or update coverage for the chosen conflict behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

In the mssql_python adapter, build_connection_config returns early when connection_string is present, so every discrete field in the same connection_config (server, database, uid, pwd, encrypt, extra, ...) is dropped without a warning or error.

# sqlspec/adapters/mssql_python/core.py
connection_string = config.pop("connection_string", None)
if connection_string is not None:
    return str(connection_string), connect_kwargs
Why it matters

A common pattern is to hold one base config and derive per-database configs from it by overriding database:

base = {"connection_string": "Server=host,1433;UID=app;PWD=...;Encrypt=yes;"}
per_db = MssqlPythonConfig(connection_config={**base, "database": "sales"})

per_db connects to the login's default database, not sales. Nothing fails — queries simply run against the wrong database, which is hard to notice when iterating over several databases on one instance.

Reproduction
from sqlspec.adapters.mssql_python.core import build_connection_config

conn_str, _ = build_connection_config(
    {"connection_string": "Server=host;UID=u;PWD=p;", "database": "sales"}
)
assert "sales" in conn_str  # fails: "Server=host;UID=u;PWD=p;"
Expected

Either of these would remove the silent wrong answer:

  1. Merge discrete fields with the explicit string, with a documented precedence. The arrow_odbc adapter already does this (its build_connection_config composes the discrete fields and appends connection_string as a suffix, with the precedence described in the docstring), so the two ODBC-style adapters would behave the same way.
  2. Raise a ValueError (or ImproperConfigurationError) when connection_string is combined with any connection-string-level field, naming the conflicting keys.

Option 1 seems the friendlier of the two, provided the precedence is stated (an explicit field overriding the same key inside the string is the least surprising for the per-database case above).

Version

sqlspec 0.63.1; still present on main.

Lingua principale
Python
Stelle
104
Fork
9
Merge medio
1g 4h
PR unite (30g)
44

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di litestar-org/sqlspec

Tutte le issue di litestar-org/sqlspec

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.