Don't lock versions into compiled constants, underpinning shared lib could be

updated and we'd never know.

FossilOrigin-Name: bb2f3334eee618c651acc8cd9859554f97ac29589145b17ac5d41b0f8bbada70
This commit is contained in:
mahlon 2025-03-31 23:15:45 +00:00
parent b40af50154
commit 5847c8dbf0
5 changed files with 9 additions and 11 deletions

View file

@ -34,14 +34,14 @@ versions might work. Don't count too heavily on it. :-)
| v0.8.2 | v0.1.0 |
You can use the `kuzuVersionCompatible()` function (along with the
`KUZU_VERSION` and `KUZU_LIBVERSION` constants) to quickly check if things are
looking right.
`kuzuGetVersion()` and the `KUZU_VERSION` constant) to quickly check if things
are looking right.
```nim
import kuzu
echo KUZU_VERSION #=> "0.1.0"
echo KUZU_LIBVERSION #=> "0.8.2"
echo kuzuGetVersion() #=> "0.8.2"
echo kuzuVersionCompatible() #=> true
```

View file

@ -31,14 +31,14 @@ include
proc kuzuVersionCompatible*(): bool =
## Returns true if the system installed Kuzu library
## is the expected version of this library wrapper.
result = KUZU_EXPECTED_LIBVERSION == KUZU_LIBVERSION
result = KUZU_EXPECTED_LIBVERSION == $kuzuGetVersion()
when isMainModule:
echo "Nim-Kuzu version: ", KUZU_VERSION,
". Expected library version: ", KUZU_EXPECTED_LIBVERSION, "."
echo "Installed Kuzu library version ", KUZU_LIBVERSION,
" (storage version ", KUZU_STORAGE_VERSION, ")"
echo "Installed Kuzu library version ", kuzuGetVersion(),
" (storage version ", kuzuGetStorageVersion(), ")"
if kuzuVersionCompatible():
echo "Versions match!"
else:

View file

@ -3,8 +3,5 @@
const KUZU_VERSION* = "0.1.0"
const KUZU_EXPECTED_LIBVERSION* = "0.8.2"
let KUZU_LIBVERSION* = $kuzu_get_version()
let KUZU_STORAGE_VERSION* = kuzu_get_storage_version().int
let KUZU_DEFAULT_CONFIG* = kuzu_default_system_config()

View file

@ -3,5 +3,6 @@
import re
import kuzu
assert KUZU_LIBVERSION.contains( re"^\d+\.\d+\.\d+(?:\.\d+)?$" )
let version = $kuzuGetVersion()
assert version.contains( re"^\d+\.\d+\.\d+(?:\.\d+)?$" )

View file

@ -2,5 +2,5 @@
import kuzu
assert KUZU_STORAGE_VERSION >= 36
assert kuzuGetStorageVersion() >= 36