Commits

adamv committed d1f2cb2

* Adding a django patch for table names with spaces into this repo, in case the filed bug gets rejected or whatever.
* regex lookup tweak.

Comments (0)

Files changed (3)

django-patches/7504-handle-table-name-spaces.diff

+Index: inspectdb.py
+===================================================================
+--- inspectdb.py	(revision 7508)
++++ inspectdb.py	(working copy)
+@@ -18,7 +18,7 @@
+ 
+         introspection_module = get_introspection_module()
+ 
+-        table2model = lambda table_name: table_name.title().replace('_', '')
++        table2model = lambda table_name: table_name.title().replace('_', '').replace(' ', '')
+ 
+         cursor = connection.cursor()
+         yield "# This is an auto-generated Django model module."

django-patches/README.txt

 This folder contains any patches needed against Django itself.
 
-There are currently no patches needed for this backend, as the 
-queryset-refactor branch has landed on djano-trunk, and much of 
-the custom hacks previously required can now be supported directly
-as backend customizations.
+7504-handle-table-name-spaces.diff
+* Patches inspectdb to handle table names with spaces.

src/sqlserver_ado/base.py

 		if settings.DATABASE_ENGINE == 'sqlserver_ado' and \
 				hasattr(settings, 'DATABASE_MSSQL_REGEX') and \
 				settings.DATABASE_MSSQL_REGEX:
-			
 			# Case sensitivity
-			match_option = 0
-			if lookup_type == 'regex':
-				match_option = 1
+			match_option = {'iregex':0, 'regex':1}[lookup_type]
 				
 			return "dbo.REGEXP_LIKE(%s, %s, %s)=1" % (field_sql, cast_sql, match_option)
 		else: