From 39d95fb6ada99c59d47fa0eae6d3128abafe2d58 Mon Sep 17 00:00:00 2001 From: Marc Tamlyn Date: Sat, 10 Jan 2015 18:13:28 +0000 Subject: Fixed #24092 -- Widened base field support for ArrayField. Several issues resolved here, following from a report that a base_field of GenericIpAddressField was failing. We were using get_prep_value instead of get_db_prep_value in ArrayField which was bypassing any extra modifications to the value being made in the base field's get_db_prep_value. Changing this broke datetime support, so the postgres backend has gained the relevant operation methods to send dates/times/datetimes directly to the db backend instead of casting them to strings. Similarly, a new database feature has been added allowing the uuid to be passed directly to the backend, as we do with timedeltas. On the other side, psycopg2 expects an Inet() instance for IP address fields, so we add a value_to_db_ipaddress method to wrap the strings on postgres. We also have to manually add a database adapter to psycopg2, as we do not wish to use the built in adapter which would turn everything into Inet() instances. Thanks to smclenithan for the report. --- django/contrib/postgres/fields/array.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'django/contrib/postgres/fields/array.py') diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py index 318afabd2c..b0850b92e7 100644 --- a/django/contrib/postgres/fields/array.py +++ b/django/contrib/postgres/fields/array.py @@ -70,9 +70,9 @@ class ArrayField(Field): size = self.size or '' return '%s[%s]' % (self.base_field.db_type(connection), size) - def get_prep_value(self, value): + def get_db_prep_value(self, value, connection, prepared=False): if isinstance(value, list) or isinstance(value, tuple): - return [self.base_field.get_prep_value(i) for i in value] + return [self.base_field.get_db_prep_value(i, connection, prepared) for i in value] return value def deconstruct(self): -- cgit v1.2.1