git-svn-id: https://svn.bolloretelecom.eu/opensource/django-ldapdb/trunk@847
e071eeec-0327-468d-9b6a-
08194a12b294
kwargs['max_length'] = 200
super(CharField, self).__init__(*args, **kwargs)
+ def get_db_prep_value(self, value):
+ """Returns field's value prepared for interacting with the database
+ backend.
+
+ Used by the default implementations of ``get_db_prep_save``and
+ `get_db_prep_lookup```
+ """
+ return value.replace('\\', '\\5c')
+ .replace('*', '\\2a')
+ .replace('(', '\\28')
+ .replace(')', '\\29')
+ .replace('\0', '\\00')
+
class ImageField(fields.Field):
pass
from django.test import TestCase
from django.db.models.sql.where import Constraint, AND, OR
+from ldapdb.models.fields import CharField
from ldapdb.models.query import WhereNode
+class FieldTestCase(TestCase):
+ def test_db_prep(self):
+ field = CharField()
+
class WhereTestCase(TestCase):
def test_single(self):
where = WhereNode()