Beispiel #1
0
 def prep_for_like_query(self, x):
     """Prepares a value for use in a LIKE query."""
     # see EXASolution_User_Manual_5.0.13-en.pdf, section 2.7.2 List of predicates: [NOT] LIKE
     # _ and % have special meaning inside LIKE comparisons...
     # if they appear in the search string we need to escape them
     return smart_text(x).replace(r'_', r'\_').replace(r'%', r'\%')
     return x
Beispiel #2
0
 def value_to_db_datetime(self, value):
     """
     Transform a datetime value to an object compatible with what is expected
     by the backend driver for datetime columns.
     """
     if value is None:
         return None
     if self.connection._DJANGO_VERSION >= 14 and settings.USE_TZ:
         if timezone.is_aware(value):
             # pyodbc donesn't support datetimeoffset
             value = value.astimezone(timezone.utc).replace(tzinfo=None)
     if not self.connection.features.supports_microsecond_precision:
         value = value.replace(microsecond=0)
     return smart_text(value)
Beispiel #3
0
 def prep_for_like_query(self, x):
     """Prepares a value for use in a LIKE query."""
     # http://msdn2.microsoft.com/en-us/library/ms179859.aspx
     return smart_text(x).replace('\\', '\\\\').replace('[', '[[]').replace('%', '[%]').replace('_', '[_]')
Beispiel #4
0
 def prep_for_like_query(self, x):
     """Prepares a value for use in a LIKE query."""
     # http://msdn2.microsoft.com/en-us/library/ms179859.aspx
     return smart_text(x).replace("\\", "\\\\").replace("[", "[[]").replace("%", "[%]").replace("_", "[_]")