>
>> Reading sqlites manual,
>> this is _supposed_ to work, but doesn't seem to. However and
>> furthermore, you don't really get autoincrement behavior from sqlite
>> unless you add in the SQL keyword "AUTOINCREMENT" when creating the
>> table.
>>
>> Django does not do this currently, so I hacked in an option in
>> db.models, so I can now do:
>
> That's not the right solution. You're making the symptom go away, not
> fixing the problem itself.
>
> Your observation is correct: the SQLite backend doesn't add
> AUTOINCREMENT. The fix is to make it always add AUTOINCREMENT. An
> AutoField is an auto-increment field: it's not optional.
>
> Shows how infrequently AutoField's are really used in practice.  
> They're
> generally just not that useful to specify.
>
> Anyway, if you you'd like to fix your patch to always do this for the
> SQLite backend, that would be great (it looks like a one-line patch to
> django/db/backends/sqlite/creation.py).

Malcolm, in fact the fix is not this easy unfortunately. I assume you  
mean for me to just add "AUTOINCREMENT" in sqlite/creation.py like so:

'AutoField': 'integer',   ->    'AutoField':  'integer autoincrement',

That does not do the trick however. The resulting sql becomes:
...
"user_id" integer AUTOINCREMENT NOT NULL PRIMARY KEY,
...

Which is not ok, sqlite requires it to be:
...
"user_id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
...

I don't see a simple way to make this happen. Doesn't seem like any  
other backend DB requires similar behavior, so there is no support for  
suffixing the sql table creation line like that.
Do you have any ideas for what the best solution would be?

Thanks
Alec

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to