within system.install, we are trying to insert some default setting values into some "serial" field, which will cause error in case of MSSQL. e.g.
<?php
db_query("INSERT INTO {users} (uid,name,mail) VALUES(0,'','')");
?>
details: in case of MSSQL, we can use IDENTITY(1, 1) for auto increment, when implementing "serial" field. by using this, we will also able to fetch session last inserted id by calling @@IDENTITY (please refer to http://drupal.org/node/74308#comment-289704). BTW, MSSQL don't allow manually insert value into such IDENTITY field; we will able to do so, unless explicitly unlock/lock table by setting INSERT_IDENTITY, which will not be a suitable solution for drupal...
suggestion: simply follow the rules of using "serial": always left its value as blank during INSERT, and let its auto generate feature function, even for system installation. we may UPDATE (or some other handling) its id after a complete INSERT. BTW, this also means we will "give up" the first id value. e.g. change the following (system.install:246) from:
<?php
db_query("INSERT INTO {users} (uid,name,mail) VALUES(0,'','')");
?>
into:
<?php
db_query("INSERT INTO {users} (name,mail) VALUES('','')");
db_query("UPDATE {user} SET uid = 0 WHERE uid = 1");
?>
Comments
Comment #1
hswong3i commentedfollow up: sorry that it is not even able to UPDATE an IDENTITY field in MSSQL:
we may need to find some other solutions... may be don't set the field as serial as default; after insert default system value, then change its type into serial manually?
Comment #2
hass commentedsubscribe
Comment #3
hswong3i commented@killes: thanks for your information, as it is a similar case as MySQL:
i will try for a similar handling for MSSQL, e.g.:
Comment #4
(not verified) commented