2. Editing data

Query window

The Query Window lets you create queries, as well as select and edit data. To open a new query window, select Query → New Query Window from the menu or right-click a connection and select Open Query Window.

images/data_editor/empty_query_window.png

Query area

The query area is a text field where you can write SQL queries. It supports syntax highlighting and autocompletion.

Keyboard shortcuts:

  • ⌘/Ctrl + Enter - run current query
  • ⌘/Ctrl + Space - stop running query

Data area

The data area displays query result. Left-click any cell to enter navigation mode.

Navigation mode keyboard shortcuts:

  • Left, Right, Up, Down - navigate between cells
  • PageUp, PageDown - scroll by one page of rows
  • Home, End or ⌘/Ctrl + Left, ⌘/Ctrl + Right - move cursor to first/last column
  • Shift + Home, Shift + End or ⌘/Ctrl + Up, ⌘/Ctrl + Down - move cursor to a first/last row
  • Enter, F2 - enter cell edit mode
  • ⌘/Ctrl + C, ⌘/Ctrl + Insert - copy cell value as text
  • ⌘/Ctrl + V, Shift + Insert - paste into current cell
  • Delete, Backspace - reset cell changes
  • Menu key or Application key - open context menu for the current cell

Edit cell mode shortcuts:

  • Enter - save and exit edit mode
  • Tab - save and move to next cell
  • Escape - discard changes and exit edit mode

Status area

The status area is used for the fetch progress bar and result summary. On success, it displays the number of rows fetched and the fetch time. On error, it shows the exception message.

Select from table

You can open a query window directly from the Project Explorer or from a layout via the context menu:

Edit mode

There is no dedicated 'edit mode'. Once table data has appeared, you can start editing your data immediately. Simple double-click on a cell you want to edit or use Enter or F2 in navigation mode.

There is only requirement to enter cell edit mode: fetched data must have a primary key for this column. Without it, OrmFactory can not build update statement.

You can also edit joined tables, as long as the target cell belongs to a table with primary key in fetched data.

Once you change a cell, it will be marked with an orange triangle in the top-left corner:

Editing a cell in a joined table affects all rows with the same primary key value.

After editing, three buttons will appear: Apply, Preview, and Discard.

  • Apply - apply changes directly to the database (no preview)
  • Preview - open a popup with generated SQL before applying
  • Discard - cancel all changes

Preview example:

images/data_editor/preview_data_changes.png

Foreign key tooltip

images/data_editor/foreign_key_tooltip.png

When you hover over a foreign key cell, OrmFactory will fetch and show data from the referenced object.

The Foreign key tooltip feature works with both real and virtual foreign keys.

The Foreign key tooltip is a recursive feature. You can point FK field in a tooltip to get a new tooltip with the object referenced by the field of referenced object.

Multiline edit

If a cell contains multiline text, OrmFactory opens a Multiline Editor:

images/data_editor/multiline_editor.png

You can also explicitly open it via the context menu -> Multiline Edit (for text cells only).

Multiline cells are marked with a return symbol on the right.

The Multiline Editor supports syntax highlighting for XML and JSON:

images/data_editor/xml_hightlighting.png

JSON Prettify-on-the-fly

Prettify-on-the-fly feature allows to edit a formatted JSON when it actually is stored as minified.

images/data_editor/prettify-on-the-fly.png

When OrmFactory detects a JSON format and recognizes it as minified, it will prettify the text and minify it back after changes. "Save minified" checkbox will appear, if OrmFactory will recognize text as JSON. This checkbox allows you to convert minified JSON to prettified and vice versa.

Insert rows

To insert a new row, simply fill in the last (empty) row. A new blank row will appear below it automatically.

Delete rows

To delete a row, right-click and choose Delete Row:

images/data_editor/delete_row.png

And yes, you can delete a row in a joined table the same way as you can edit a joined table cell. Marked for delete rows will be shown with red strikethrough. The delete operation can be canceled using the context menu on the marked row. OrmFactory does not care if you want to change a cell before delete the whole row. It will generate update before delete. Delete and edit can be discarded separately from context menu.

Expressions

You can enter expressions into cells. These expressions are sent as-is to the database and evaluated there. If the OrmFactory cannot recognize the date, it considers the text to be an expression and sends it to the DBMS as is. Text fields cannot be an expression.

images/data_editor/cells_expressions.png

Error handling

If an update fails, changed cells in affected row will show red triangles. Hover to see the error message.

images/data_editor/cell_update_error.png

Data reloading

After update or insert has been applied, OrmFactory will reload exact state of the changed rows. It will replace all cells of changed rows, no matter was they been edited or not. Reloading the entire row is necessary if triggers were used or, for example, current_timestamp as a default expression. Deleted row will be removed from grid.