Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique sequence with Model.objects.bulk_create([...]) #3

Closed
mkuchen opened this issue Apr 6, 2017 · 1 comment
Closed

Unique sequence with Model.objects.bulk_create([...]) #3

mkuchen opened this issue Apr 6, 2017 · 1 comment

Comments

@mkuchen
Copy link

mkuchen commented Apr 6, 2017

Hey @aaugustin @rmoch - I'm working on a project that needs to support some unfortunate functionality in a backwards compatible way in one of our tables. I'm using PostgreSQL 9.5.2, Django 1.9, and Python 2.7.11.

The model in need of the sequencing looks like this:

class Profile(models.Model):
    uid = models.AutoField(primary_key=True)
    unique_archaic_code = models.CharField(max_length=12L, unique=True)

We cannot change the structure of the Profile model - any performance enhancements we make on it must be backwards compatible. Otherwise I would say to heck with the unique_archaic_code system we have set up and make something more modern.

unique_archaic_code follows a specific alpha-numeric pattern. I generate values for it in the Python layer at the moment, but I want to abstract this out into a PostgreSQL SEQUENCE for obvious performance reasons, so we can potentially use a Django bulk_create statement that will make bulk creation of Profile objects with proper unique_archaic_codes possible.

unique_archaic_code must stay, and must continue to be filled with values that follow the old pattern defined in the Python layer - I want to replace that value filling with the sequencing your package appears to support.

Does this package support that functionality currently?

@aaugustin
Copy link
Owner

aaugustin commented Apr 6, 2017

I don't think this package will help you with the functionality you're describing.

It's designed to produce values for the Python layer. It cannot work with bulk_create.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants