Skip to content

Editing cells whilst in "View" ? #1320

Closed

Description

@shaun-ba

Details for the issue

Can't edit cells whilst in view mode, I'm assuming this isn't a bug but expected behaviour.

I found this feature (view), whilst executing an SQL statement as suggested in another issue, to sort the data by two columns. This is just great because it is a must for me to see rows sorted in this way. However, I then can't edit the row, so I have to change back to the table view and find the row again to edit it, which seems counter productive?

I'm opening this issue because:

DB4S needs a feature

I'm using DB4S on:

Linux: (Ubuntu 16.04)

I'm using DB4S version:

3.10.99

Activity

  1. justinclift commented on Feb 16, 2018

    @justinclift
    Member

    Interesting. We started adding initial support for doing stuff with views in #141, which made it's way into the 3.10.x release series.

    From reading through #141 (comment), it sounds like updates should be working already though. So... you might be hitting a bug after all. 😉

  2. added
    bugConfirmed bugs or reports that are very likely to be bugs.
    on Feb 16, 2018
  3. chrisjlocke commented on Feb 16, 2018

    @chrisjlocke
    Member

    @shaun-ba might be referring to the 'Execute SQL' tab view though, rather than database Views... (but I might be wrong) ...

  4. justinclift commented on Feb 16, 2018

    @justinclift
    Member

    Oh yeah, good point. Re-reading, it does sound like that. 😄

  5. mgrojo commented on Feb 16, 2018

    @mgrojo
    Member

    @shaun-ba, if you are refering to the 'Execute SQL' tab, you can use the button with tooltip 'Save the results view' to save the results as an SQL view and then you will be able to follow the instructions in #141 (comment) to update that view from the 'Browse Data' tab. Let us know if that works for you, please.

  6. shaun-ba commented on Feb 16, 2018

    @shaun-ba
    Author
  7. chrisjlocke commented on Feb 16, 2018

    @chrisjlocke
    Member

    I'll add this to the wiki, as it must be a pretty interesting addition.

  8. shaun-ba commented on Oct 12, 2018

    @shaun-ba
    Author

    @mgrojo This doesn't work which is why i created the issue, granted i didn't know this was still open.

    When i assign a unique column and then try to edit a column it just says "Error changing data"

  9. mgrojo commented on Oct 12, 2018

    @mgrojo
    Member

    @shaun-ba No worries 😄

    Have you added a INSTEAD OF trigger and defined the pseudo primary key? In case the primary key is a composite, I think we still don't support that. But I suppose you could then add the rowid of the table in that case (except if it's a WITHOUT ROWID table, of course). What's your case? How is the schema of your table?

    References:

    https://www.sqlite.org/lang_createview.html

    You cannot DELETE, INSERT, or UPDATE a view. Views are read-only in SQLite. However, in many cases you can use an INSTEAD OF trigger on the view to accomplish the same thing.

    https://www.sqlite.org/lang_createtrigger.html#instead_of_trigger

    Triggers may be created on views, as well as ordinary tables, by specifying INSTEAD OF in the CREATE TRIGGER statement. If one or more ON INSERT, ON DELETE or ON UPDATE triggers are defined on a view, then it is not an error to execute an INSERT, DELETE or UPDATE statement on the view, respectively. Instead, executing an INSERT, DELETE or UPDATE on the view causes the associated triggers to fire. The real tables underlying the view are not modified (except possibly explicitly, by a trigger program).

    #141 (comment)

    By default, views are still locked from editing because most databases don't have triggers in place for editing views. This means you have to enable editing for a view by browsing it, right clicking on the column headers, and clicking "Unlock view editing". You'll then be asked for the name of a unique column in that view. That's because we somehow have to decide how to address rows in the view and there doesn't seem to be any good way to find out a suitable column automatically.

  10. shaun-ba commented on Oct 12, 2018

    @shaun-ba
    Author

    @mgrojo I've not done anything except trying what was suggested in this thread: #141

    I assumed after adding the unique column via the prompt it should just work as didn't see any other steps?

    My SQL knowledge is limited which is why I'm using this UI! :)

  11. mgrojo commented on Oct 13, 2018

    @mgrojo
    Member

    @shaun-ba

    I assumed after adding the unique column via the prompt it should just work as didn't see any other steps?

    You're right that in that comment there is no mention to needing the triggers, but they are indeed mandatory for a view to be editable. If you read the whole issue or read the sqlite.org pages I linked, you'll find information and examples about them.

    The editable views is the only workaround to the date for multi-column sorting, but there is also an enhancement request for that #1409. You can subscribe to the issue and you'll receive a notification if we finally implement it.

  12. shaun-ba commented on Oct 16, 2018

    @shaun-ba
    Author

    @mgrojo Ok thanks i will try that, however on skimming it all again i see that i can't insert from here, so that kind of renders it useless for my purposes.

    I need to check a long list of different numbers (sorted) and then add a row if it doesn't exist

  13. chrisjlocke commented on Oct 16, 2018

    @chrisjlocke
    Member

    Could you not open the database in two copies of DB4S? One showing the view, and the other in 'Browse Data' tab allowing you to add rows as needed?

  14. chrisjlocke commented on Oct 16, 2018

    @chrisjlocke
    Member

    I assumed after adding the unique column via the prompt it should just work as didn't see any other steps?

    I thought it always worked like that too. I thought setting the unique field was dependant on which column you wanted to edit (ie, which table it derived from) - obviously a view can pull fields from multiple tables.

  15. shaun-ba commented on Oct 16, 2018

    @shaun-ba
    Author

    @chrisjlocke I guess that's an option as long as having two copies open won't cause issue!

  16. chrisjlocke commented on Oct 16, 2018

    @chrisjlocke
    Member

    You can have a thousand copies open. Its not like you're editing each one all at the same time.
    While in the middle of editing one record, you can't edit another (in a separate application), as the database will be locked. This is a 'bug' (sort of*) with DB4S. In an ideal world, the database wouldn't be locked until you clicked the 'Write Changes' button, so it would only be locked for milliseconds, not while you're scratching your head the whole time you're editing a record.

    *This is because each time you edit a cell and move cells, a database update occurs. This is secure as in the event of a program crash, you haven't lost all your edits. In the applications I write, a database update only occurs when the user has finished editing a whole record. This has its dangers, but doesn't touch the database until its necessary. Swings and roundabouts, as they say.

  17. mgrojo commented on May 3, 2020

    @mgrojo
    Member

    Both #141 and #1409 are already closed, so I'm closing this as well, which either duplicate or a question, which was already answered. @shaun-ba you can test it using our 3.12.0 alpha release or a nightly build.

  18. added and removed
    bugConfirmed bugs or reports that are very likely to be bugs.
    on May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions