Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#19083 closed Bug (invalid)

postgresql_psycopg2 backend - rename get_version to get_pg_version

Reported by: toms.baugis@… Owned by: nobody
Component: Database layer (models, ORM) Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

the problem is with this function:
https://github.com/django/django/blob/master/django/db/backends/postgresql_psycopg2/version.py#L24

get_version function normally is expected to just return module version without asking for params.

tools like raven that on crashes are reporting module versions fail in the case of this module (bug filed https://github.com/getsentry/raven-python/issues/143) because the get_version here does something else and expects a connection

renaming the function to something like get_postgres_version solves the issue

Change History (3)

comment:1 by Łukasz Rekucki, 12 years ago

Resolution: invalid
Status: newclosed

get_version function normally is expected to just return module version without asking for params.

Expected by whom? The most popular convention I've seen is using __version__ (which is what PEP 396 will also define).

comment:2 by toms.baugis@…, 12 years ago

raven is the backend for sentry that makes it possible to follow traces in production in an easy manner. one thing that is does is trying to pull out versions from all the modules

a sample search:
http://code.ohloh.net/search?s=%22get_version%22&browser=Default&pp=0&fl=Python&fd=mdef&mp=1&ml=0&me=1&md=1&ff=1&filterChecked=true

Shows that there are quite a few cases where the version is missing and much less often function by name get_version is expecting any vars.

Filing a bug against all these cases so that raven could rely only on version is unfeasible, but changing the function name in django posgtres backend to get_db_version would be trivial and also an arguably better function name.

comment:3 by toms.baugis@…, 12 years ago

the underlined "version" in the comment above were meant to be ___version___ of course

Note: See TracTickets for help on using tickets.
Back to Top