mirror of
				https://github.com/django/django.git
				synced 2025-10-26 07:06:08 +00:00 
			
		
		
		
	Add a truncate_name method to shorten DB identifiers for Oracle
git-svn-id: http://code.djangoproject.com/svn/django/branches/boulder-oracle-sprint@3972 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
		| @@ -1,4 +1,5 @@ | ||||
| import datetime | ||||
| import md5 | ||||
| from time import time | ||||
|  | ||||
| class CursorDebugWrapper(object): | ||||
| @@ -92,6 +93,16 @@ def typecast_boolean(s): | ||||
| def rev_typecast_boolean(obj, d): | ||||
|     return obj and '1' or '0' | ||||
|  | ||||
| def truncate_name(name, length=None): | ||||
|     """Shortens a string to a repeatable mangled version with the given length. | ||||
|     """ | ||||
|     if length is None or len(name) <= length: | ||||
|         return name | ||||
|      | ||||
|     hash = md5.md5(name).hexdigest()[:4] | ||||
|      | ||||
|     return '%s%s' % (name[:length-4], hash) | ||||
|  | ||||
| ################################################################################## | ||||
| # Helper functions for dictfetch* for databases that don't natively support them # | ||||
| ################################################################################## | ||||
|   | ||||
		Reference in New Issue
	
	Block a user