I ran into an issue when upgrading my web application from django-ldapdb 0.9.0 to 1.3.0 (because it is packaged in Debian Buster). It creates migrations that fail.
It seems that django-ldapd enforce dn
as a primary key for the models (see here, but I don't want to hack django-ldapdb nor can I avoid migrations in my app ), so I tried removing the existing primary key in the model, but that didn't work...
Here is an example of one of the models creating buggy migrations (worked fine in 0.9.0) :
class LdapServiceUserGroup(ldapdb.models.Model):
"""
Class for representing an LDAP userservice entry.
Un group user de service coté ldap. Dans userservicegroupdn
(voir dans settings_local.py)
"""
# LDAP meta-data
base_dn = LDAP['base_userservicegroup_dn']
object_classes = ['groupOfNames']
# attributes
name = ldapdb.models.fields.CharField(
db_column='cn',
max_length=200,
)
members = ldapdb.models.fields.ListField(
db_column='member',
blank=True
)
def __str__(self):
return self.name
So when running makemigrations
it creates a migrations which set dn
as a primary key. And then :
File "/usr/lib/python3/dist-packages/MySQLdb/connections.py", line 292, in query
_mysql.connection.query(self, query)
django.db.utils.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server ver
sion for the right syntax to use near ')' at line 1")
(full error is here but not really relevant)