Closed gino0631 closed 2 years ago
The result for the number of elements in the database should be in the framework in the $res variable under the index "COUNT(*)", which worked fine for all my tests. But in your case it is under the index "count" :
"res":{
"count":280627
}
Before fixing this, I would like to understand, why is it different in your setup. Which database type are you using?
Which database type are you using?
PostgreSQL 12.7
Ok, I can reproduce the issue with PostgreSQL. I would have expected the API to abstract from the database used, so that this is not happening. But good to know that this also needs to be tested. It probably does not make sense to wait for the API to be fixed, but to make code that cover both ways. When I do this I run into another Problem with PostgreSQL. I need more time to look into this.
Thank you for taking a look.
Maybe COUNT(*)
and count
are just different names for that column that different DBMS create, and you should not rely on them. Instead, maybe it is possible to specify an alias somehow ("SELECT COUNT(*) AS X"), or retrieve the result in a different way.
I'm not a specialist in PHP frameworks, but maybe this will make sense.
Thanks, that is the right solution and I found how to do it in the framework. Now it seems to work the same in all DBs.
If you do not want to wait for the next release you could manually change the file "/srv/nextcloud/apps/geoblocker/lib/Db/RIRServiceMapper.php" in line 85 from return intval($res['COUNT(*)']);
to return intval($res['count']);
in the Postgres case.
The other problem I saw afterwards was just a local test issue on my system, so it should work fine this way.
After setting the Service to "RIRData" and pressing "Update Database", the following message is displayed:
Version info: GeoBlocker: 0.5.1 Nextcloud: 21.0.4
The
oc_geoblocker_ls_rir
table does exist and contains 280627 rows.The log file contains multiple entries of the following info: