File tree Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Expand file tree Collapse file tree 3 files changed +16
-10
lines changed Original file line number Diff line number Diff line change
1
+ bugfixes :
2
+ - postgresql_ping - fix pg version parsing (https://github.com/ansible-collections/community.postgresql/issues/315).
3
+ - postgresql_info - fix pg version parsing (https://github.com/ansible-collections/community.postgresql/issues/315).
Original file line number Diff line number Diff line change 506
506
sample: false
507
507
'''
508
508
509
+ import re
509
510
from fnmatch import fnmatch
510
511
511
512
try :
@@ -956,13 +957,13 @@ def get_pg_version(self):
956
957
query = "SELECT version()"
957
958
raw = self .__exec_sql (query )[0 ][0 ]
958
959
full = raw .split ()[1 ]
959
- tmp = full . split ( '.' )
960
+ m = re . match ( r"(\d+)\.(\d+)(?:\.(\d+))?" , full )
960
961
961
- major = int (tmp [ 0 ] )
962
- minor = int (tmp [ 1 ]. rstrip ( ',' ))
962
+ major = int (m . group ( 1 ) )
963
+ minor = int (m . group ( 2 ))
963
964
patch = None
964
- if len ( tmp ) >= 3 :
965
- patch = int (tmp [ 2 ]. rstrip ( ',' ))
965
+ if m . group ( 3 ) is not None :
966
+ patch = int (m . group ( 3 ))
966
967
967
968
self .pg_info ["version" ] = dict (
968
969
major = major ,
Original file line number Diff line number Diff line change 91
91
version_added: 1.7.0
92
92
'''
93
93
94
+ import re
95
+
94
96
try :
95
97
from psycopg2 .extras import DictCursor
96
98
except ImportError :
@@ -136,13 +138,13 @@ def get_pg_version(self):
136
138
self .is_available = True
137
139
138
140
full = raw .split ()[1 ]
139
- tmp = full . split ( '.' )
141
+ m = re . match ( r"(\d+)\.(\d+)(?:\.(\d+))?" , full )
140
142
141
- major = int (tmp [ 0 ] )
142
- minor = int (tmp [ 1 ]. rstrip ( ',' ))
143
+ major = int (m . group ( 1 ) )
144
+ minor = int (m . group ( 2 ))
143
145
patch = None
144
- if len ( tmp ) >= 3 :
145
- patch = int (tmp [ 2 ]. rstrip ( ',' ))
146
+ if m . group ( 3 ) is not None :
147
+ patch = int (m . group ( 3 ))
146
148
147
149
self .version = dict (
148
150
major = major ,
You can’t perform that action at this time.
0 commit comments