Modify

Ticket #638 (assigned defect)

Opened 3 years ago

Last modified 19 months ago

platform-dependent constraint name hash

Reported by: lmartine3@… Owned by: andrew
Priority: major Milestone: 1.0
Component: databaseapi Version: 0.7.2
Keywords: Cc:

Description

Constraint names in south appear to use the python built in hash
function which results in either 32 or 64 bit hashed names, depending
on your platform. The django core, however, forces constraint names
into a 32 bit hash irregardless of the platform (see
http://code.djangoproject.com/ticket/9253, although the fix there is
not what is in the latest 1.2 django).

The result is that, on a 64 bit machine, constraint names generated
during a south 'db.create_unique' do not match the output from
'manage.py sqlclear'.

As with django core, a fixed 32 bit hash is probably the best solution, although it will cause problems for previously created constraints.

Attachments

Change History

comment:1 follow-up: ↓ 3 Changed 3 years ago by andrew

  • Status changed from new to assigned
  • Milestone set to 1.0

This is only a problem for indexes, actually - constraint names don't matter for all practical purposes (South detects the names using information_schema anyway).

comment:2 Changed 3 years ago by jackdied@…

Stable names for indexes would be nice. Unfortunately even if you had a pure-python version of the hashing algo you would have to check both versions on a miss. There's no guarantee that hash(obj) will stay the same between major versions or architectures. Python 2.6 and 2.7 have the same code for hashing but I didn't check any earlier versions.

comment:3 in reply to: ↑ 1 Changed 2 years ago by draganHR@…

Replying to andrew:

This is only a problem for indexes, actually - constraint names don't matter for all practical purposes (South detects the names using information_schema anyway).

If you want to db.rename_column first you need to drop constraint, right?
And to do that you need to know their names, right?

comment:4 Changed 19 months ago by Matthew

I have come across this issue today, because after a South migration that creates a new many-many table, I am now unable to run 'manage.py reset' because that command tries to drop a constraint with its own name, which does not match the name South has created it with.

View

Add a comment

Modify Ticket

Action
as assigned
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.