mongodb-labs / django-mongodb

MongoDB Backend for Django
Apache License 2.0
2 stars 5 forks source link

implement SchemaEditor.add/alter/remove_field() #115

Open timgraham opened 4 weeks ago

timgraham commented 4 weeks ago

Should these operations try to follow what Django does on SQL backends as much as possible?

For example, if adding a field with a default, Django will populate the default value on existing rows. Should MongoDB do it? If so, what about if there's no value to be populated? Should the field not be added to existing documents? We might be able to do that for nullable fields, but perhaps not for string-based fields where null=False and the default is an empty string.

Jibola commented 3 weeks ago

I'm willing to take a group vote here, but here's my take:

Questions:

if adding a field with a default, Django will populate the default value on existing rows. Should MongoDB do it?

Yes

If so, what about if there's no value to be populated? Should the field not be added to existing documents?

The field SHOULD be added to reduce bug issues; this is a point I am willing to discuss

My larger sentiment is let's keep to how Django handles SQL backends generally to reduce any potential errors that could arise from assumptions made elsewhere in the code.

Considerations :