diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-01-24 22:31:34 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-01-24 22:31:34 +0100 |
| commit | f310205a283cae4b9675801f4c6e32817a2536a7 (patch) | |
| tree | 9e27e047077a6fb0032a83c2e7a9cfd8532a653f /crates/cli/src | |
| parent | 62c3ddf5b722a5e412855b097f7f12a600bb5b78 (diff) | |
| download | mihi-f310205a283cae4b9675801f4c6e32817a2536a7.tar.gz mihi-f310205a283cae4b9675801f4c6e32817a2536a7.zip | |
words: make alternative relationships two-ways
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à <mssola@mssola.com>
Diffstat (limited to 'crates/cli/src')
| -rw-r--r-- | crates/cli/src/words.rs | 12 |
1 files changed, 11 insertions, 1 deletions
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<String>) -> 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}."); |
