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

Issue with add site tree item (using ms-sql) #162

Open
mikecaro opened this issue Jun 26, 2015 · 4 comments
Open

Issue with add site tree item (using ms-sql) #162

mikecaro opened this issue Jun 26, 2015 · 4 comments
Labels

Comments

@mikecaro
Copy link

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).

@idlesign
Copy link
Owner

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.

@dani0805
Copy link

dani0805 commented Oct 4, 2015

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

@dani0805
Copy link

dani0805 commented Oct 4, 2015

ignore my previous comment. it is the tree_id which is 1 and it is of course ok. Still debugging

@dani0805
Copy link

dani0805 commented Oct 4, 2015

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.

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

No branches or pull requests

3 participants