Issue with add site tree item (using ms-sql)
mikecaro opened this issue · 4 comments
I can only add one site tree item to a site tree. When I attempt to add a second, I get this error:
('23000', "[23000] [Microsoft][SQL Server Native Client 11.0][SQL Server]Violation of UNIQUE KEY constraint 'sitetree_treeitem_tree_id_15363010_uniq'. Cannot insert duplicate key in object 'dbo.sitetree_treeitem'. The duplicate key value is (1, ). (2627) (SQLExecDirectW); [01000] [Microsoft][SQL Server Native Client 11.0][SQL Server]The statement has been terminated. (3621)")
Please let me know how I can help (clarifications, more detail, etc).
Sorry, completely missed that issue out.
I haven't tested sitetree neither on Windows nor on MS SQL.
I do not have such an environment, so the best I could do is to keep this issue open, so we could wait for someone who has an appropriate experience.
Hi,
I have the same problem here. What I see is that although the form does not pass the id as value, by the time the sql gets generated the insert has id = 1
C:\Python27\lib\site-packages\django\db\backends\utils.py in execute
class CursorDebugWrapper(CursorWrapper):
# XXX callproc isn't instrumented at this time.
def execute(self, sql, params=None):
start = time()
try:
return super(CursorDebugWrapper, self).execute(sql, params) ...
finally:
stop = time()
duration = stop - start
sql = self.db.ops.last_executed_query(self.cursor, sql, params)
self.db.queries_log.append({
'sql': sql,
▼ Local vars
Variable Value
self
<django.db.backends.utils.CursorDebugWrapper object at 0x0000000005C302E8>
stop
1443988139.048
start
1443988139.04
params
(u'Authorization Requests',
u'',
u'administration:manage_auth_requests',
True,
1,
False,
None,
u'',
True,
False,
True,
True,
False,
False,
1,
4,
0)
sql
u"QUERY = u'SET NOCOUNT ON INSERT INTO [sitetree_treeitem] ([title], [hint], [url], [urlaspattern], [tree_id], [hidden], [alias], [description], [inmenu], [inbreadcrumbs], [insitetree], [access_loggedin], [access_guest], [access_restricted], [access_perm_type], [parent_id], [sort_order]) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s); SELECT CAST(SCOPE_IDENTITY() AS BIGINT)' - PARAMS = (u'Authorization Requests', u'', u'administration:manage_auth_requests', 1, 1, 0, None, u'', 1, 0, 1, 1, 0, 0, 1, 4, 0)"
duration
0.00800013542175293
ignore my previous comment. it is the tree_id which is 1 and it is of course ok. Still debugging
At least for me the problem is the alias. If it is empty I get the error above. The database is set up correctly to allow nulls. Not sure what is going on but if you are having this problem just make sure you fill the alias.