Skip to content

Data Editing: How to insert/delete rows? #20

Closed
@eirikbakke

Description

@eirikbakke

When working with tables in an external relational database, such as PostgreSQL, it is possible to use Ultorg to edit data from any perspective (visual query), using the Data Editing Mode button in the toolbar:

DataEditingModeButton

With this mode enabled, you can edit primitive values in any database table by moving the cursor to the relevant cell and typing, like in a spreadsheet. Changes will appear in a "staged" state, and committed to the database in a single transaction only once you press the "Apply Edits" button:

Staged Simple Edit

You can also insert and delete rows, by using the key combinations Ctrl+Shift+Minus and Ctrl+Shift+Plus. (That's the plus/minus keys between 0 and Backspace, not on the numeric keypad.) The Ctrl+Shift+Minus action can also be used to revert any selected existing staged edits. Undo/Redo works here as well, until you press Apply Edits, after which committed changes cannot be undone.

TODO: Make the keyboard shortcuts work with +/- on the numeric keypad too.
TODO: Make these keyboard shortcuts documented in the user interface.

Pressing Ctrl+Shift+Minus will put the currently selected row in a pending delete state (red/strikeout):

Staged Deletion

Pressing Ctrl+Shift+Plus will show a "pending insert" row in green, where values for the new record can be entered:

Staged Insert

When inserting new rows, it's usually best to make all of the table's available fields visible first, as done above, since you'd usually want to fill in values for them. In the example above, Ultorg has already populated the "Course ID" field, because the insert operation was done with the cursor located in one of the sections for the course with ID=3, in a perspective that has Sections joined on Courses on these two fields.

There are a few caveats for the row insertion feature (and fixing these are on the Ultorg TODO list):

  • You will usually need to specify a primary key. In the screenshot above, Ultorg is showing a placeholder value "+1" that the user should change to a new primary key value. In the future, Ultorg will auto-generate primary keys at commit time, in columns for which this is enabled.
  • In some perspectives, the inserted row may fail to show up in the expected place, in particular when the Custom Group feature has been used. In this case the status bar will show the message "Not all edits are currently visible", and it's usually best to invoke Undo to get out of this state. This problem will be fixed in a future Ultorg version.
  • After staging some edits, it is still possible to make modifications to the perspective, e.g. to show additional fields. But if you apply filters, or make other changes to the query, the edits you had previously staged may no longer be visible (e.g. because they were in rows that are now filtered out). This will also cause the "Not all edits are currently visible" message to appear. It's best to keep the query in a state where all edits are visible before pressing Apply Edits, and future versions of Ultorg might enforce this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions