Whole file

joke2k/django-environ

The author described this change as fix[db_url_config]: added postgres cluster DSN support (ie postgresql://username:password@host1:port1,host2:port2/database). It counts as a record because the check below fails on the code as it stood at 509cf7737 and passes on 0ca26c55c, with nothing else changed between the two runs.

Fix saved2021-12-09
Sharing licenceMIT · LICENSE.txt
Change size+19 2

What the code was meant to do, written into the code itself as a save note

fix[db_url_config]: added postgres cluster DSN support (ie postgresql://username:password@host1:port1,host2:port2/database)

The change

1212 """
1313
1414 import ast
15+import itertools
1516 import logging
1617 import os
1718 import re
501502 if url.port:
502503 path += ':{port}'.format(port=url.port)
503504
505+ if url.scheme in cls.POSTGRES_FAMILY and ',' in url.netloc.rsplit('@', 1)[-1]:
506+ # Parsing postgres cluster dsn
507+ hostinfo = list(
508+ itertools.zip_longest(
509+ *(
510+ host.rsplit(':', 1)
511+ for host in url.netloc.rsplit('@', 1)[-1].split(',')
512+ )
513+ )
514+ )
515+ hostname = ','.join(hostinfo[0])
516+ port = ','.join(filter(None, hostinfo[1])) if len(hostinfo) == 2 else ''
517+ else:
518+ hostname = url.hostname
519+ port = url.port
520+
504521 # Update with environment configuration.
505522 config.update({
506523 'NAME': path or '',
507524 'USER': _cast_urlstr(url.username) or '',
508525 'PASSWORD': _cast_urlstr(url.password) or '',
509- 'HOST': url.hostname or '',
510- 'PORT': _cast_int(url.port) or '',
526+ 'HOST': hostname or '',
527+ 'PORT': _cast_int(port) or '',
511528 })
512529
513530 if (

The check that tells the two apart

failpass·tests/test_db.py::test_db_parsing[postgres_cluster]

Check file tests/test_db.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before it509cf7737363a56e4464962dbae4ab72b801c7b3
Broken version dated2021-11-21
Moduleenviron.environ
Units changedEnv
Fingerprint9e84dd77fdeb0d78
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in joke2k/django-environ