Skip to content

Commit

Permalink
Fix #1238 for mariadb versions
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvlk committed Aug 24, 2023
1 parent bbf65cb commit 26a26f4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions pyplanet/apps/contrib/rankings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ async def check_database_compatibility(self):
if self.instance.db.server_info.type == "postgresql":
raise NotImplementedError("Rankings app only works on PyPlanet instances running on MySQL.")

logger.info('DB Information: {} ({})'.format(self.instance.db.server_info.type, self.instance.db.server_info.version))
# Database engines starting from MySQL 8.0 / MariaDB 10.2 support the PARTITION BY query.
# The query without PARTITION BY is unsupported in newer versions.
if self.instance.db.server_info.type == "mysql" and \
Expand Down
4 changes: 2 additions & 2 deletions pyplanet/core/db/server_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def __init__(self, engine, db):
async def determine(self):
if isinstance(self.db.engine, peewee.MySQLDatabase):
self.type = "mysql"
query = "SELECT @@version AS version, @@innodb_version AS innodb_version"
query = "SELECT @@version AS version"
elif isinstance(self.db.engine, peewee.PostgresqlDatabase):
self.type = "postgresql"
query = "SHOW SERVER_VERSION"
Expand All @@ -41,8 +41,8 @@ async def determine(self):

if self.type == "mysql":
# Use the innodb_version (1) for a clean engine version, use the version (0) as version text.
self.version = result[1]
self.version_text = result[0]
self.version = self.version_text.split('-')[0]

if "mariadb" in self.version_text.lower():
self.type = "mariadb"
Expand Down

0 comments on commit 26a26f4

Please sign in to comment.