Code

Opened 21 months ago

Closed 21 months ago

Last modified 20 months 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: master
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

Attachments (0)

Change History (3)

comment:1 Changed 21 months ago by lrekucki

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

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 Changed 20 months ago by toms.baugis@…

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 Changed 20 months ago by toms.baugis@…

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.