shaib avatar shaib committed 50eea21

Changes to the generic backend for MSSQL support

Comments (0)

Files changed (1)


     create_primary_key_string = "ALTER TABLE %(table)s ADD CONSTRAINT %(constraint)s PRIMARY KEY (%(columns)s)"
     delete_primary_key_sql = "ALTER TABLE %(table)s DROP CONSTRAINT %(constraint)s"
     backend_name = None
+    default_schema_name = "public"
     def __init__(self, db_alias):
         self.debug = False
             return False
             return True
+    def _get_schema_name(self):
+        try:
+            return self._get_setting('schema')
+        except (KeyError, AttributeError):
+            return self.default_schema_name
     def _possibly_initialise(self):
         if not self._initialised:
         # First, change the type
         params = {
             "column": self.quote_name(name),
-            "type": self._db_type_for_alter_column(field)            
+            "type": self._db_type_for_alter_column(field),            
+            "table_name": table_name
         # SQLs is a list of (SQL, values) pairs.
             ifsc_table = "constraint_column_usage"
             ifsc_table = "key_column_usage"
-        if self._has_setting("SCHEMA"):
-            schema = self._get_setting("SCHEMA")
-        else:
-            schema = "public"
+        schema = self._get_schema_name()            
         # First, load all constraint->col mappings for this table.
         rows = self.execute("""
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.