I maintain the django-jsonfield module, and I have, as the documentation
suggests, some relatively expensive code in JSONField.db_type.
The documentation is pretty clear on this as being _the_ place to put a
test like this (that checks to see if the database can handle a json field
type, or if we should just store it as text).
https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#custom-database-types
"The
db_type()<https://docs.djangoproject.com/en/dev/howto/custom-model-fields/#django.db.models.Field.db_type>
method
is only called by Django when the framework constructs the CREATE TABLE
statements
for your application – that is, when you first create your tables. It’s not
called at any other time, so it can afford to execute slightly complex
code, such as the connection.settings_dict check in the above example."
However, I noticed that the SQL query I was running to check for if I
should use a json field was running way more than expected.
It turns out that this method is called at:
https://github.com/django/django/blob/master/django/db/models/sql/where.py#L368
All other calls to this method appear to be in CREATE statements.
Is this something that just slipped under the radar? Is it something that
should be fixed in documentation? Any suggestions?
Regards,
Matt.
--
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/3b0084b2-da32-420b-a9b1-dc4bcd4ffe46%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.