MySQL<v5.6.4 does not support millisecond precision in its DATETIME fields (as opposed to other databases). This meant that Attributes, which do rely on millisecond precision for creating their object hashes, got out of sync in a horrible way on MySQL (Issue 362). This revision fixes the problem by going to second-level precision if a too-low version of MySQL is detected (this should not be an issue since mysql does not reuse its pks anyway).

This commit is contained in:
Griatch 2013-05-14 19:15:58 +02:00
parent 95268406ab
commit a533232885
2 changed files with 21 additions and 1 deletions

View file

@ -39,3 +39,13 @@ class ServerConfigManager(models.Manager):
if not conf:
return default
return conf[0].value
def get_mysql_db_version(self):
"""
This is a helper method for getting the version string of a mysql database.
"""
from django.db import connection
conn = connection.cursor()
conn.execute("SELECT VERSION()")
version = conn.fetchone()
return version and str(version[0]) or ""