Connecting to SQL Azure

Issue #26 resolved
Anonymous created an issue

With a SQL Database in Azure there is no problem connecting and using the database. However, when I run 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 repo owner
    • 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 repo owner

    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