Fix > 9 PostgreSQL version numbering

This commit is contained in:
Feike Steenbergen
2016-07-18 10:35:23 +02:00
parent 13b4306f40
commit f7c44945b7
+3 -3
View File
@@ -981,7 +981,7 @@ $$""".format(name, ' '.join(options)), name, password, password)
>>> Postgresql.postgres_version_to_int('9.3.13')
90313
>>> Postgresql.postgres_version_to_int('10.1')
100100
100001
>>> Postgresql.postgres_version_to_int('10')
Traceback (most recent call last):
...
@@ -997,8 +997,8 @@ $$""".format(name, ' '.join(options)), name, password, password)
if len(components) < 2 or len(components) > 3:
raise Exception("Invalid PostgreSQL format: X.Y or X.Y.Z is accepted: {0}".format(pg_version))
if len(components) == 2:
# new style verion numbers, i.e. 10.1
components.append('0')
# new style verion numbers, i.e. 10.1 becomes 100001
components.insert(1, '0')
try:
result = [c if int(c) > 10 else '0{0}'.format(c) for c in components]
result = int(''.join(result))