From f310205a283cae4b9675801f4c6e32817a2536a7 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Sat, 24 Jan 2026 22:31:34 +0100 Subject: words: make alternative relationships two-ways MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'alternative' relationship was only being created on a single direction when calling 'words dup', while in this case it should go both ways so the 'words show' command can pick things up easily. Considering how I don't think I'll have too many words to begin with, this sort of duplication shouldn't be too troublesome, and it makes code easier. Signed-off-by: Miquel Sabaté Solà --- crates/cli/src/words.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'crates/cli') diff --git a/crates/cli/src/words.rs b/crates/cli/src/words.rs index e7aadcb..a54e679 100644 --- a/crates/cli/src/words.rs +++ b/crates/cli/src/words.rs @@ -599,15 +599,25 @@ fn dup(mut args: IntoIter) -> i32 { return 1; }; - // Create the word, set it as an alternative, and attach the given tags. + // Create the word. If successful, then we move into relationships and tags. match mihi::create_word(updated) { Ok(word_id) => { + // Set it as an alternative. This goes both ways, so two + // relationships have to be inserted with both directions. if let Err(e) = mihi::add_word_relationship(source_id, word_id, RelationKind::Alternative) { println!("errors: words: {e}."); return 1; } + if let Err(e) = + mihi::add_word_relationship(word_id, source_id, RelationKind::Alternative) + { + println!("errors: words: {e}."); + return 1; + } + + // Attach tags. for tag in selected_tags { if let Err(e) = mihi::attach_tag_to_word(tag.id as i64, word_id) { println!("warning: words: {e}."); -- cgit v1.2.3