@@ -35,14 +35,26 @@ func compareDatabaseConditionalToActual(conditional string, result *collect.Data
3535 return false , errors .New ("unable to parse postgres connected analyzer" )
3636
3737 case "version" :
38+ //semver requires major.minor.patch format to successqfully compare versions.
39+ if compVer := strings .Split (parts [2 ], "." ); len (compVer ) == 2 {
40+ parts [2 ] = fmt .Sprintf ("%s.%s.0" , compVer [0 ], compVer [1 ])
41+ } else if len (compVer ) == 1 {
42+ parts [2 ] = fmt .Sprintf ("%s.0.0" , compVer [0 ])
43+ }
44+ if compVer := strings .Split (result .Version , "." ); len (compVer ) == 2 {
45+ result .Version = fmt .Sprintf ("%s.%s.0" , compVer [0 ], compVer [1 ])
46+ } else if len (compVer ) == 1 {
47+ result .Version = fmt .Sprintf ("%s.0.0" , compVer [0 ])
48+ }
49+
3850 expectedRange , err := semver .ParseRange (fmt .Sprintf ("%s %s" , parts [1 ], parts [2 ]))
3951 if err != nil {
4052 return false , errors .Wrap (err , "failed to parse semver range" )
4153 }
4254
4355 actual , err := semver .Parse (result .Version )
4456 if err != nil {
45- return false , errors .Wrap (err , "failed to parse actual psotgres version" )
57+ return false , errors .Wrap (err , "failed to parse actual postgres version" )
4658 }
4759
4860 return expectedRange (actual ), nil
0 commit comments