Needs review
Project:
OG Vocabulary
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
16 Jan 2013 at 21:59 UTC
Updated:
7 Jul 2014 at 08:37 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
geek-merlinserial field is primary key, so other keys only unique.
here's the fix.
Comment #2
amitaibuWouldn't SQL complain if there's no primary key?
Comment #3
czigor commentedNeither MySQL nor SQLite complains about the lack of primary key. I don't know what the patch exactly does (i.e. what the id and vid fields are) but now the install works. I will try to investigate this further.
Comment #4
czigor commentedThe last sentence of http://sqlite.org/autoinc.html says: "Any attempt to use AUTOINCREMENT on a WITHOUT ROWID table or on a column other than the INTEGER PRIMARY KEY column results in an error."
This means that a serial type field in a hook_schema() should become a primary key in sqlite and that's how it is done by DatabaseSchema_sqlite, too. If, however, in addition to a serial field another primary key is given in hook_schema(), there will be an attempt to create two primary keys which is impossible.
It seems that in MySQL an AUTO_INCREMENT field does not need to be PRIMARY KEY.
So with the patch in #1 the id field will be a primary key in sqlite while with mysql there will be no primary keys.
To make things more uniform I suggest to make array('id') the primary key. As id is a serial field I see no reason to add the vid to the primary key anyway. Also, og_vocab_update_7000() suggests that in the drupal 7 version only the id field is meant to be the primary key.
Comment #5
discipolo commentedI am grateful for this fix since without it I cannot install with sqlite database!