* refactor: move formula field-reference visitors from premium to core
* feat: add ButtonField model and fixture (#1722)
* feat: add read-only button field type backend (#1722)
* feat: resolve database formulas client-side for the button field (#1722)
* feat: add button field type frontend (#1722)
* chore: add changelog entry for button field (#1722)
* fix: disable button field cells when the url formula is broken (#1722)
* fix: encode whitespace in resolved button field urls (#1722)
* fix: rename button field visitor tests to avoid pytest module collision
* test: add button field to expected premium export outputs
* test: add button field to remaining interesting-table test expectations
Registering the button field in construct_all_possible_field_kwargs
changed the interesting test table used by several golden-output
tests. Update the affected expectations (serialized row value, CSV
export column, and generated schema entry) to match actual behavior.
* feat: put the button field behind the button-field feature flag
* fix: address button field review nits
* fix: renumber button field migration after develop merge
* docs: describe the button field as an action field in API docs
* fix: handle raw formulas and missing field references in button fields
* fix(review): remap binary-op field refs, cache parse trees, extend button field tests
- visit both operands in BaserowFormulaReplaceFieldReferences.visitBinaryOp so
get() references inside binary expressions are remapped on import/duplication
- cache client-side formula parse trees so large grids do not re-parse the same
button formula for every row
- add tests for the urlInvalid submission block, the field-store fallback in
functional grid cells, and duplication with broken field references
* fix: keep button field type registered when the feature flag is off
Gating registration behind the flag meant that disabling it after button
fields existed made every registry lookup for those fields raise, breaking
all row, field and export endpoints for the affected tables.
The type is now always registered on both backend and frontend, matching
how other gated field types work. Creating a button field (or converting
a field to one) is rejected with ERROR_FEATURE_DISABLED while the flag is
off, and the field type dropdown hides the type entirely via the new
isVisibleInDropdown hook. Existing button fields keep rendering and their
tables keep working.
* fix: keep brackets when remapping field references in formulas
* fix: keep the button url formula mode when remapping field references
Assigning the remapped formula string to `url_formula` made the patched
`save()` re-wrap it through `to_python` as `simple` mode, undoing the
raw-mode guard in `replace_field_id_references`. A raw literal URL then
became an unparseable formula, so duplicating a table left the button
broken. Assign the whole formula object so mode and version survive.
* fix(review): share the formula field id cache and cover the flag-off cases
Move `get_table_field_ids` and its `table_schema_changed` invalidation into
core next to the visitors, so validating a button field's url formula no
longer costs a query per field on every field response. The AI prompt
validation now reads the same cache instead of its own copy.
Also list the edited field's own type in the field form dropdown even when
hidden, otherwise an existing button field renders with a blank type once
the feature flag is turned back off, and drop the always-null cell backup
on type conversion.
* chore(review): tidy the button field export branch and flag docs spacing
* test: cover the formula parse tree cache
The cache is shared by every resolveFormula caller, including the builder,
so record what it guarantees: one parse per distinct formula, raw formulas
never parsed, failures not cached, and oldest-first eviction at the cap.
Also state the read-only invariant the reuse depends on.
* fix: guard and cache the formula field reference helpers (#1722)
`get()` and `get('fields')` both parse and both pass the create API, so
remapping them raised an uncaught IndexError that aborted the whole
duplication or import job. Guard every index instead.
`extract_field_id_dependencies` also parsed raw formulas, unlike its two
sibling helpers, and re-parsed on every call. It now short-circuits raw
mode and caches the extracted ids per formula string.
* fix: keep the AI prompt's mode when remapping field references (#1722)
Moving the reference visitors to core added a raw short-circuit that
returns a bare string. `AIFieldType.after_import_serialized` re-saved
that string, so `to_python` re-wrapped a raw natural language prompt as
`simple` mode and every row's generation then failed on parsing the
prose.
Assign the whole formula object instead, the same way the button field
already does, and cover a raw prompt surviving an export/import.
* feat: add the encode_uri and encode_uri_component formula functions (#1722)
A button field's URL is built by concatenating row values, so a value
holding a reserved character corrupts it: `shoes#7` truncates to a
fragment and `a&b=1` injects a parameter. Encoding every value
automatically is not an option, because a value can legitimately be the
whole URL.
These mirror the two functions that already exist in the database
formula language and let a formula escape the parts that need it. The
backend and the browser encode identically, since button URLs resolve
client-side and everything else resolves on the server.
* fix: address review on the button field backend (#1722)
The field no longer creates a database column. It held nothing but an
always-null boolean, and that boolean leaked into the API docs and the
Local Baserow schema. `get_model_field` returns None and a
`NoDatabaseColumnField` is contributed to the generated model instead,
which Django treats as non concrete. A `ButtonFieldConverter` handles
conversion in both directions, since the lenient schema editor cannot
alter into or out of a column-less field, and the serializer is now
always-null while staying writable so the read-only validator still
rejects a write.
Also from review: only creation is gated by the feature flag, so an
existing button field stays editable with the flag off; dependencies are
read off the cached table model rather than two queries per field; and
the client is only told to re-fetch when a referenced field appears or
disappears, not when one is renamed or retyped.
* fix: address review on the button field frontend (#1722)
Without a label the button showed the percent-encoded URL. The URL is
now resolved once as the user built it and only the href is encoded, so
the label reads `https://example.com/Red Button` while the link points
at `Red%20Button`. With no label and no URL it reads "Click me".
Also from review: a read-only field the search cannot match no longer
disables optimistic row updates for every edit in a searched view, which
a valueless field like this one did; the parse tree cache evicts the
least recently used entry rather than the oldest inserted one; and the
field type reports its icon class statically and no longer claims its
cells are booleans in the API docs.
* fix: hide button fields from public views and require a label (#1722)
Button fields are no longer handed to visitors of a publicly shared view.
A new `FieldType.can_be_in_public_view` flag drives the exclusion, applied
to the public view info endpoint, the public rows queryset and the two
public websocket signal paths, so a visible field option isn't enough to
expose the label and the URL formula.
The label is now mandatory. It's the only text a button shows, so it must
be set when the field is created or converted into a button, and it can't
be emptied afterwards. The client-side fallbacks to the resolved URL and
to a default label are gone with it.
* fix: call JobType.on_error hook again when a job fails
The call was accidentally dropped in e0a07588a, leaving the documented
post-transaction error hook dead. Job types rely on it to persist error
details that would otherwise be lost to the rolled-back job transaction.
* feat: record data sync runs as jobs and show the sync history
Periodic data syncs now run through the job system on behalf of the
authorized user, so every sync run (manual or periodic) is recorded as a
SyncDataSyncTableJob with a triggered_by discriminator. A new JobType
scoping hook lets the generic jobs listing expose runs started by other
users after a ListDataSyncJobsOperationType permission check, on both the
type-filter and job_ids polling paths. The frontend shows a paginated run
history (state, trigger, user, time, duration, error) in the data sync
configuration modal and below the manual sync modal, live-updating
through the existing job store poller.
* fix: address feedback
* feat(database): add starts with view filter type
Adds a new "starts_with" view filter that keeps rows whose field value
begins with the filter value (case-insensitive), with both backend and
web-frontend implementations including the real-time row-match check.
Supported field types: text, long text, url, email, phone number, number,
autonumber, single select, and text/char/url/number/single_select formulas.
Closes#1943
* test(web-frontend): update view filter form snapshot for starts with filter
* fix(database): address review feedback on starts with filter
- Use toSearchableString in the frontend startsWithFilter so real-time
matching stays consistent with the backend for formatted number fields;
delegate FormulaFieldType.startsWithFilter to the underlying field type so
number/select formulas stay consistent too
- Don't trim the row value in genericStartsWithFilter (backend only strips the
filter value, not the stored cell), avoiding leading-whitespace divergence
- Fix misleading docstrings on StartsWithViewFilterType and starts_with_query
- Add backend coverage for a non-text (number) formula and a frontend test for
a formatted number field
- Link changelog entry to issue #1943
* fix(database): delegate starts_with filter on AI fields
Address review feedback on PR #5624:
- Delegate starts_with_query / getStartsWithFilterFunction on the premium
AIFieldType so AI fields filter correctly instead of silently matching
every row (backend Q() / frontend () => false fallthrough).
- Add backend and frontend regression tests for the AI-field gap.
- Remove the unreachable FormulaFieldType.getStartsWithFilterFunction.
- Rename genericStartsWithFilter's second arg to searchableRowValue.
- Trim the StartsWithViewFilterType docstring to its behavioral sentence.
* docs(database): note starts_with compatibility via get_compatible_filter_field_type
* feat: add first(), last() and generalized index() formula functions
* fix: address PR review feedback and handle NaN index argument
- Rename _BaserowIndexShortcut to BaserowIndexShortcut (drop leading _)
- Remove unnecessary comments and section separators
- Rename variable c to clone in JSONBArrayGetElement
- Rename test to test_first_and_last_return_scalar_values, drop docstring
- Remove step comments in test_index_generalized.py
- Handle NaN/div-by-zero as index() argument (returns null instead of crash)
* feat: update index() formula examples to include array fields
* feat: add array_slice() database formula function
* fix(formula): handle NaN arguments in array_slice to prevent DB crash
Wrap start/count args with handle_arg_being_nan before truncating to
int, so expressions like tonumber('x') no longer cause
"cannot convert NaN to integer" at the PostgreSQL level.
NaN is treated as 0 for both arguments.
* feat: add ARRAYUNIQUE() database formula function (#2326)
Add array_unique() formula that removes duplicate values from lookup
arrays, preserving first-occurrence order. Mirrors Airtable's
ARRAYUNIQUE() — operates on true arrays from lookup fields, not plain
text.
Supports text, number, boolean, date, duration, URL, email, phone,
rating, single select, multiple select, link row, created_on, and
autonumber sub-types. Rejects file fields (different JSONB structure).
* feat: enable count() and join() composability with array_unique()
Add internal non-aggregate functions (array_length, array_join_values)
that operate on JSONB arrays directly, and wire them into count() and
join() so that count(array_unique(...)) and join(array_unique(...), sep)
work. The existing many-expression paths remain unchanged.
* docs: add array_unique to formula docs, mark internals as exceptions
Add array_unique to formula_docs.md so the formula prompt completeness
tests pass. Add array_length and array_join_values (internal delegation
targets) to the formula_exceptions lists in both test files.
* chore: ensure tests works also for formulas referencing different field types
* Fix missing early return when data source is missing
* Fix missing file_import job type in frontend registry
* Restore trigger waiting message
* Tweak the margin-bottom if the first alert. If there's an alert below it, the combination of bottom+top is too much.
---------
Co-authored-by: peter_baserow <peter@baserow.io>