Closed smurthys closed 6 years ago
I chose to convert current server's version from int to string for two reasons (instead of converting the input string version number to int):
Thank you @smurthys for adding this useful function. Everything works well on 9.4 and 10.
The only small thing that I noticed was the use of v
as a variable. While it is rather easy to guess the meaning of v, there aren't many places, if any, in ClassDB where it isn't immediately evident what a variable means. With v
it took me a few seconds to make sure I knew the meaning. To me it doesn't fit into the nomenclature of ClassDB where it is normally easily readable. It seems like using version
instead of v
would fit better. However, it might be just me overthinking this and it is worth a small discussion.
Looks great, thanks for updating the implementation @smurthys. The functions work as expected and tests pass on versions 9.6 and 10, and converting from int to string is certainly ideal all things considered.
I have two minor suggestions:
Add a test in testServerVersionComparers.sql
that uses the old versioning scheme but with a 0
second part (for example, asserting that ClassDB.intServerVersionToString(90005) = '9.0.5'
). It seems like such a test will pass without issue, but the case is distinct enough that it might warrant a test.
The comment on L68 of addServerVersionComparersCore.sql
seems unfinished (ends with 'and` and does not point to a second source of information on the next line).
I also agree with @KevinKelly25's suggestion about replacing v
with a more descriptive variable name.
Thank you for the review. It seems like I forgot to replace the variable name I had used in the version I had developed in pgAdmin. Thanks for catching that.
I just pushed changes that address the three issues pointed out. Because a parameter name changed, please run the following query before running the revised script. This step is not required in production:
DROP FUNCTION ClassDB.intServerVersionToString(INT);
Thanks for the reviews.
This PR makes the following changes:
ClassDB.intServerVersionToString
to convert a machine-readable pg server version number to stringserver_version_num
instead of 'server_version' in functionClassDB.getServerVersion
ClassDB.compareServerVersion
addServerVersionComparersCore.sql
asIMMUTABLE
Fixes #263 #267