Editing cells whilst in "View" ? #1320
Copy link
Copy link
Closed
Description
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
Reactions are currently unavailable
Activity
justinclift commentedon Feb 16, 2018
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. 😉
chrisjlocke commentedon Feb 16, 2018
@shaun-ba might be referring to the 'Execute SQL' tab view though, rather than database Views... (but I might be wrong) ...
justinclift commentedon Feb 16, 2018
Oh yeah, good point. Re-reading, it does sound like that. 😄
mgrojo commentedon Feb 16, 2018
@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.
shaun-ba commentedon Feb 16, 2018
chrisjlocke commentedon Feb 16, 2018
I'll add this to the wiki, as it must be a pretty interesting addition.
shaun-ba commentedon Oct 12, 2018
@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"
mgrojo commentedon Oct 12, 2018
@shaun-ba No worries 😄
Have you added a
INSTEAD OFtrigger 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 aWITHOUT ROWIDtable, of course). What's your case? How is the schema of your table?References:
https://www.sqlite.org/lang_createview.html
https://www.sqlite.org/lang_createtrigger.html#instead_of_trigger
#141 (comment)
shaun-ba commentedon Oct 12, 2018
@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! :)
mgrojo commentedon Oct 13, 2018
@shaun-ba
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.
shaun-ba commentedon Oct 16, 2018
@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
chrisjlocke commentedon Oct 16, 2018
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?
chrisjlocke commentedon Oct 16, 2018
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.
shaun-ba commentedon Oct 16, 2018
@chrisjlocke I guess that's an option as long as having two copies open won't cause issue!
chrisjlocke commentedon Oct 16, 2018
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.
mgrojo commentedon May 3, 2020
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.