You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you change the uid field to not be a primary key, the following function of ldabdb.models.Model fails generating the dn (distingushed name), as it looks for fields which are defined with primary_key=True.
defbuild_rdn(self):
""" Build the Relative Distinguished Name for this entry. """bits= []
forfieldinself._meta.fields:
iffield.db_columnandfield.primary_key:
bits.append("%s=%s"% (field.db_column,
getattr(self, field.name)))
ifnotlen(bits):
raiseException("Could not build Distinguished Name")
return'+'.join(bits)
If you leave it and execute makemigrations, it generates a migration for changing the uid field. Executing migrate fails then, because it is not possible to define multiple PK fields.
So the logic of the LDAP module requires to define a second PK, but database-wise this is not possible. I don't really know what the solution is here. Maybe we need to override the build_rdn() function to check for a property that doesn't break the DB instead of primary_key
Workaround:
Delete the new migrations file in accounts/migrations manually after makemigrations.
The text was updated successfully, but these errors were encountered:
Maybe we can just release our own version based on the current version including the fix. Probably this is the easiest solution without breaking current functionality? Otherwise we would have to rework a lot when switching to another module I assume
Or we just extend and override the build_rdn() function in tapir.
But I'm not sure what the implications are when we do that
accounts.models.LdapPerson
defines 2 PKs, one in the implementation and one in its base class.tapir/accounts/models.py
LdapPerson
inherits fromldabdb.models.Model
:If you change the
uid
field to not be a primary key, the following function ofldabdb.models.Model
fails generating thedn
(distingushed name), as it looks for fields which are defined withprimary_key=True
.If you leave it and execute
makemigrations
, it generates a migration for changing theuid
field. Executingmigrate
fails then, because it is not possible to define multiple PK fields.So the logic of the LDAP module requires to define a second PK, but database-wise this is not possible. I don't really know what the solution is here. Maybe we need to override the
build_rdn()
function to check for a property that doesn't break the DB instead ofprimary_key
Workaround:
Delete the new migrations file in
accounts/migrations
manually aftermakemigrations
.The text was updated successfully, but these errors were encountered: