SQLite: Locating and restoring custom-defined cards

Discussion in 'Pleco for iPhone / iPad / iPod Touch' started by etm001, Mar 25, 2016.

  1. etm001

    etm001 状元

    Hi,

    I'd like to revert all my custom-defined cards that have been linked to a dictionary entry back to their custom definitions. In SQLite, I used this command to locate these cards:

    • SELECT * FROM pleco_flash_cards WHERE pleco_flash_cards.defn NOTNULL AND pleco_flash_cards.dictid!=-1
    This returned 487 results. I'd like to confirm this command is correct. If so, I'd like to confirm the SQL command to revert the cards to their original definitions. From what I can tell, custom cards by default have a value of -1 for dictcreator, dictid and dictentry, but I'm not sure if it's as simple as updating those values to -1.

    Thanks!
     
  2. mikelove

    mikelove 皇帝 Staff Member

    It is that simple, yes.

    Any particular reason why you changed your mind about linking them? Asking because this will be a lot harder in future revisions of our database and I'd like to make sure the relevant need is covered somehow.
     
  3. etm001

    etm001 状元

    I'd like to keep the custom-defined cards as they were originally created (they usually are definitions provided in textbooks, etc.)

    I should note that, given my current learning style, I'm 100% OK with creating duplicate cards. In this post the other day, I asked about adding duplicate cards when an existing custom card existed. I noted:
    And then asked:
    I have both "Duplicate (in cat)" and "Duplicate (not cat)" set to "Create new card" in flashcard settings.

    It's not the end of the world if a custom card is linked to a dictionary entry - I just reset the definition as I encounter these cards, but given my huge pool of cards and/or how I focus on subsets of my pool, I might not come across one of these cards for a very long time.
     
  4. Shun

    Shun 状元

    Hi,

    currently I achieve the same thing by importing the custom-defined flashcard from a text file and enabling "Store in user dict". Since you can switch your flashcards back and forth between user dictionaries and other dictionaries (or return them all to user dictionary definitions using Batch), you never have to worry about losing custom definitions.

    Since I use the system a lot, allow me to make a gedankenexperiment about the next version:

    In a future release of Pleco, I think user dictionaries will still be possible, but they will be create-once, read-only and very fast. If you only have a "monolithic flashcard database" with parts of it acting as a dictionary, what would perhaps be needed is a way to protect cards with custom definitions inside those directories in the database from accidental edits (from the [+] button, or later imports). If you have this structure,

    Flashc. structure.png

    the distinction between protected and unprotected shouldn't come into play when a user edits a card directly. But when a user tries to add a card from a regular dictionary using the [+] button or imports a card that already exists in the protected part, there should be a mechanism preventing this. Then, the newly added card will have to be saved as a duplicate in the unprotected part. If the card isn't a duplicate, they should easily be able to import new custom definitions into the protected part. If a card in the protected part only links to a regular dictionary, it should also be replaceable without warning. Did I think it through correctly, or am I missing something?

    I think this is the most important need, that custom data entered by the user are never obscured and remain easily accessible.
     
    Last edited: Mar 25, 2016
  5. mikelove

    mikelove 皇帝 Staff Member

    @etm001 - Sorry, I somehow missed this the first time I read that message from you but I think this actually is a bug; the old definition should not be changed in this case.

    @Shun - Yes, in the new system it should be even harder to delete custom data by accident.
     
  6. etm001

    etm001 状元

    I'm still experiencing this problem in the latest version of Pleco. I don't mind running an SQL command to reset the custom definitions, but will this bug ever get fixed?
     
  7. mikelove

    mikelove 皇帝 Staff Member

    It's proven to be a bit hairier to fix than we'd like - it'll certainly go away in 4.0 but not sure if we'll manage to fix it before then since AFAIK you're the only person who's experienced it so far.

    There's actually a batch command to do to this fix now - 'restore hidden custom definitions' in Edit / Batch - so that might save a little time at least.
     
  8. etm001

    etm001 状元

    I had no idea, this is great. Thanks.
     

Share This Page