summaryrefslogtreecommitdiff
path: root/tests/model_fields
diff options
context:
space:
mode:
authorMarc Tamlyn <marc.tamlyn@gmail.com>2015-01-10 18:13:28 +0000
committerTim Graham <timograham@gmail.com>2015-01-16 16:15:16 -0500
commit39d95fb6ada99c59d47fa0eae6d3128abafe2d58 (patch)
treef514f85027835d6504a80982184467c41da601c7 /tests/model_fields
parenta17724b791275578334bcdc66b3a8113eb86605e (diff)
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.
Diffstat (limited to 'tests/model_fields')
-rw-r--r--tests/model_fields/tests.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index 897359c0cf..a9ce43cae6 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -695,6 +695,11 @@ class GenericIPAddressFieldTests(test.TestCase):
o = GenericIPAddress.objects.get()
self.assertIsNone(o.ip)
+ def test_save_load(self):
+ instance = GenericIPAddress.objects.create(ip='::1')
+ loaded = GenericIPAddress.objects.get()
+ self.assertEqual(loaded.ip, instance.ip)
+
class PromiseTest(test.TestCase):
def test_AutoField(self):