Issue #26 resolved

Connecting to SQL Azure

Anonymous avatarAnonymous created an issue

With a SQL Database in Azure there is no problem connecting and using the database. However, when I run manage.py test, the first test (I think) fails with the error: "Tables without a clustered index are not supported in this version of SQL Server." When I google that it says that you have to create the primary key like this: CREATE TABLE Source (Id int NOT NULL IDENTITY, [Name] nvarchar(max), CONSTRAINT [PK_Source] PRIMARY KEY CLUSTERED ( [Id] ASC )) So the CLUSTERED has to be added to the primary key constraint.

The issue is that I cannot find the file in which to make this change.

Comments (5)

  1. Michael Manfre
    • changed status to open

    The bit of code that is constructing this SQL is within Django and currently doesn't provide an easy way of changing the primary key constraint without having to duplicate a bunch of extra code from the core.

    The workaround for now is to have django dump the create sql and then manually alter and apply.

  2. Vernon Cole

    I have independently verified the behavior. I tried to run the adodbapi test suite against an Azure db, and indeed the first test fails as indicated. Shortly afterward I noticed a Microsoft add proclaiming that you can "Move apps to the cloud without rewriting them" which is clearly not the case here. I could not quickly spot an easy way to determine from introspection that an Azure server was on the other end of the connection. The current connection object has dbms_name and dbms_version attributes which might be used to figure this out, but it did not jump out at me. Should I continue to investigate this track?

  3. Michael Manfre

    The issue is only experienced when creating new tables, I feel that the documented workaround is good enough and avoids any Azure specific complexity added to django-mssql.

    Creating tables is more frequent when running unit tests, but the same workaround is possible with the TEST_CREATE: False option.

  4. Log in to comment
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 ProjectModifiedEvent.java.
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.