mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	fix attribute loading CTE + don't duplicate attributes in case of cloning, fixes #735
This commit is contained in:
		
							parent
							
								
									9cb8bc5dd8
								
							
						
					
					
						commit
						2595c3ac31
					
				@ -349,9 +349,9 @@ class Note extends Entity {
 | 
				
			|||||||
            tree(noteId, level) AS (
 | 
					            tree(noteId, level) AS (
 | 
				
			||||||
                SELECT ?, 0
 | 
					                SELECT ?, 0
 | 
				
			||||||
                UNION
 | 
					                UNION
 | 
				
			||||||
                SELECT branches.noteId, tree.level + 1 
 | 
					                SELECT branches.parentNoteId, tree.level + 1 
 | 
				
			||||||
                    FROM branches
 | 
					                    FROM branches
 | 
				
			||||||
                    JOIN tree ON branches.parentNoteId = tree.noteId
 | 
					                    JOIN tree ON branches.noteId = tree.noteId
 | 
				
			||||||
                WHERE branches.isDeleted = 0
 | 
					                WHERE branches.isDeleted = 0
 | 
				
			||||||
            ),
 | 
					            ),
 | 
				
			||||||
            treeWithAttrs(noteId, level) AS (
 | 
					            treeWithAttrs(noteId, level) AS (
 | 
				
			||||||
@ -371,6 +371,11 @@ class Note extends Entity {
 | 
				
			|||||||
        // we order by noteId so that attributes from same note stay together. Actual noteId ordering doesn't matter.
 | 
					        // we order by noteId so that attributes from same note stay together. Actual noteId ordering doesn't matter.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        const filteredAttributes = attributes.filter((attr, index) => {
 | 
					        const filteredAttributes = attributes.filter((attr, index) => {
 | 
				
			||||||
 | 
					            // if this exact attribute already appears then don't include it (can happen via cloning)
 | 
				
			||||||
 | 
					            if (attributes.findIndex(it => it.attributeId === attr.attributeId) !== index) {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (attr.isDefinition()) {
 | 
					            if (attr.isDefinition()) {
 | 
				
			||||||
                const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
 | 
					                const firstDefinitionIndex = attributes.findIndex(el => el.type === attr.type && el.name === attr.name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user