Filter to active items only, remove Status column, document widget binding rules
- Add WHERE item_active filter to show only active unused items - Remove Status column from query and table widget - Add widget binding guidance to AGENTS.md (NUMBER inputs cannot use NULLIF pattern due to prepared statement typing) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
16
AGENTS.md
16
AGENTS.md
@@ -101,10 +101,24 @@ Every `widgetId` across all pages must be globally unique. Use short descriptive
|
||||
- SQL source of truth: `<query_name>.txt` (readable, real newlines).
|
||||
- `metadata.json` `body` field: same SQL but JSON-escaped (`\n`, `\"`).
|
||||
- Table binding: `{{query_name.data}}`.
|
||||
- Optional date filter pattern: `NULLIF('{{Widget.selectedDate}}','') IS NULL OR ... BETWEEN ...::date AND ...::date`.
|
||||
- All production queries use `xTuple_GoLive` datasource.
|
||||
- **Database credentials are managed by Appsmith server-side** — they are not stored in this repository. The datasource JSON only contains the name and plugin reference. When developing/testing SQL queries locally, use separate read-only credentials provided by the user — never embed them in committed files.
|
||||
|
||||
### Widget Bindings in SQL (IMPORTANT)
|
||||
|
||||
Appsmith uses prepared statements (`pluginSpecifiedTemplates[0].value = true`). When a query body contains `{{Widget.property}}`, Appsmith replaces each binding with a typed prepared statement parameter (`$1`, `$2`, etc.).
|
||||
|
||||
**For DATE_PICKER_WIDGET2** (text/date type parameters):
|
||||
- The `NULLIF` pattern works: `NULLIF('{{DateWidget.selectedDate}}','')::date`
|
||||
- This is safe because the parameter is always typed as `text`.
|
||||
|
||||
**For INPUT_WIDGET_V2 with `inputType: "NUMBER"`** (integer type parameters):
|
||||
- Do **NOT** use `NULLIF('{{Widget.text}}','')::int` — this fails because Appsmith may type the parameter as `integer`, and `NULLIF(integer, '')` causes a type mismatch error (`invalid input syntax for integer: ""`).
|
||||
- Instead, use a direct cast: `'{{Widget.text}}'::int`
|
||||
- The widget's `defaultText` property ensures there is always a value on page load, so NULL/empty handling is unnecessary.
|
||||
|
||||
**General rule**: Match the SQL cast to the widget's output type. When in doubt, test with a hardcoded value first to confirm the base query works, then add the binding.
|
||||
|
||||
## Common Tasks
|
||||
|
||||
### Add a new page
|
||||
|
||||
Reference in New Issue
Block a user