Queries — overview
A query in Liberty is a named SQL statement attached to a connector (which itself points at a pool, i.e. a database). Screens, dashboards, charts, dictionary lookups, dictionary sequences and the AI assistant all consume queries — so adding a query is the most common change you'll make in the Liberty Next pages.
The page that manages queries is Liberty Next → Build → Connectors. This overview maps it; the next pages walk through each "add" path.
The Connectors page at a glance
Three regions:
| Region | What it carries |
|---|---|
| Top toolbar | Global actions — + Connector, Discard, Save. The Save button writes the connector file and triggers a hot reload — no process restart needed. |
| Left navigation | Two groups: Apps (connectors that have a menu — these are the apps users see in the top switcher) and Data sources (connectors that supply data but don't appear in the switcher). Click a name to open it on the right. |
| Right pane | The editor for the selected connector. A mode bar across the top picks one of five views — Settings…, Tables, Queries, Sequences, Lookups. |
The four kinds of queries
A connector keeps its queries in four sections; the section a query sits in is its kind:
| View | What lives here |
|---|---|
| Tables | One entry per table, holding up to four queries: get (read), post (insert), put (update), delete. They are called <table>_get, <table>_post, <table>_put, <table>_delete. The list shows a row per table with its slot badges (GET / PUT / POS / DEL). |
| Queries | Standalone queries outside a table's set — reports, bulk operations, queries called by actions, charts or dashboards. Example: monthly_revenue, purge_old_logs. |
| Sequences | Queries that return the next number for a dictionary sequence. Typical body: SELECT COALESCE(MAX(<col>), 0) + 1 FROM <table>. |
| Lookups | Queries that return codes and labels for a dictionary lookup. Typical body: SELECT <value>, <label> FROM <table>. |
Change type moves a query to another section — for example a query written under Queries that turns out to feed a lookup. When the move changes the query's name (a table slot becomes a standalone query, or the reverse), a warning lists the new name: screens, actions and dictionary entries that use the old name have to be updated.
The add buttons — one per view
| View | Button | What opens |
|---|---|---|
| Tables | + Add queries | A choice: Generate from DB (the CRUD wizard — reads the table in the database and generates the four queries) or Empty stub (asks for a table name and creates an empty read query). |
| Queries | + Add query | A name prompt, then an empty query to fill in by hand. |
| Sequences | + Add sequence | The scaffold — pick a table and a key column, see the SQL, save: it writes the query and the dictionary sequence. |
| Lookups | + Add lookup | The scaffold — pick a table, a value column, a label column and an optional filter, save: it writes the query and the dictionary lookup. |
The next pages walk through each path.
What a query carries
The query editor shows these fields:
| Field | Required | What it does |
|---|---|---|
| Name | Yes | Unique inside the connector. The query's permission is sql:<connector>:<name>. Changed with Rename, which updates every reference. |
| SQL | Yes | The statement, with :name parameters. A single text, or one variant per database (default required) — see Per-dialect SQL. |
| Writable | No (off) | Off, only a SELECT is accepted. On for INSERT / UPDATE / DELETE / CALL. |
| Params | No | Declared parameters (name, label, default) — a label and a default value for each :name. |
| Label | No | Short name shown in lists. |
| Description | No | What the query returns — shown under the table name in the Tables list. |
Save and reload — what a click does
Saving on this page is atomic across two files when needed:
| Action you took | What gets written |
|---|---|
| Created or edited a table or a query | The connector file. |
| Used the scaffold for a sequence or a lookup | The connector file and the dictionary (the new sequence or lookup in the connector's scope). |
| Cloned a connector (whole app) | A cross-file write that copies the dictionary overlay, screens, menu, charts and dashboards under the new name. Goes through a dedicated endpoint. |
| Renamed a connector, a query or a table | A cross-file update that touches every reference (screens, menus, dictionary, charts, dashboards). Refuses to run when local edits aren't saved. |
After every save the framework runs a hot reload automatically. The new query is callable immediately — no restart, no logout.
What you actually do — quick map
| Goal | Read |
|---|---|
| Generate the four CRUD queries from a real database table. | Create from a database table — the wizard path, recommended when the table exists. |
| Write a custom query (standalone, hand-written). | Create a custom query. |
| Make a copy of an existing query or of a whole application. | Clone a query or a connector. |
| Add a sequence (next id) or a lookup (dropdown source). | Sequences and lookups. |
| Pass values to a query — fixed values, other columns, the signed-in user. | Parameter binding. |
| Ship different SQL for Postgres vs Oracle. | Per-dialect SQL variants. |
What's next
- Create from a database table — start here when the table already lives in your database.
- Concepts → Connectors — the deep reference behind this page (connector kinds, pools, query lifecycle).