@saptools/cf-hana 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -10
- package/dist/cli.js +464 -62
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.js +452 -49
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -24,7 +24,7 @@ login on the hot path) and connections are pooled and reused within a process.
|
|
|
24
24
|
- **Schema introspection** — list schemas, tables, and columns.
|
|
25
25
|
- **Local SQL history** — direct SQL calls are appended to dated JSONL files
|
|
26
26
|
under `~/.saptools/cf-hana/histories/` with five-day retention.
|
|
27
|
-
- **Write backups** — CLI `UPDATE` and `DELETE` statements create a local CSV
|
|
27
|
+
- **Write backups** — CLI `UPDATE`, `UPSERT`, and `DELETE` statements create a local CSV
|
|
28
28
|
backup of matching rows before the write runs.
|
|
29
29
|
- **Compact CLI results** — CLI `SELECT`/`WITH` output is compact CSV with
|
|
30
30
|
bounded cells and optional saved refs for exact follow-up inspection.
|
|
@@ -93,7 +93,7 @@ Common options: `--refresh`, `--role <runtime|hdi>`, `--binding <name>` /
|
|
|
93
93
|
`--limit <n>`, `--no-auto-limit`. The `query` command also accepts
|
|
94
94
|
`--param <value>` (repeatable), `--cell-limit <n>`, `--save`, and
|
|
95
95
|
`--result-ttl-minutes <n>`. `tables` and `columns` still support
|
|
96
|
-
`--format <table|json|csv>`. CLI `UPDATE` and `DELETE` statements are backed up
|
|
96
|
+
`--format <table|json|csv>`. CLI `UPDATE`, `UPSERT`, and `DELETE` statements are backed up
|
|
97
97
|
automatically before the write runs.
|
|
98
98
|
|
|
99
99
|
```bash
|
|
@@ -196,26 +196,31 @@ and `columns` is not recorded as user SQL history.
|
|
|
196
196
|
|
|
197
197
|
## Write backups
|
|
198
198
|
|
|
199
|
-
When `cf-hana query` receives an `UPDATE` or `DELETE`, it first builds and runs a
|
|
199
|
+
When `cf-hana query` receives an `UPDATE`, `UPSERT`, or `DELETE`, it first builds and runs a
|
|
200
200
|
matching `SELECT`:
|
|
201
201
|
|
|
202
202
|
- `UPDATE <target> SET ... WHERE ...` becomes
|
|
203
203
|
`SELECT * FROM <target> WHERE ...`.
|
|
204
|
+
- `UPSERT <target> VALUES ... WHERE ...` becomes
|
|
205
|
+
`SELECT * FROM <target> WHERE ...`.
|
|
204
206
|
- `DELETE FROM <target> WHERE ...` becomes
|
|
205
207
|
`SELECT * FROM <target> WHERE ...`.
|
|
206
208
|
|
|
207
209
|
The backup is saved before the write runs:
|
|
208
210
|
|
|
209
211
|
```text
|
|
210
|
-
~/.saptools/cf-hana/backups
|
|
211
|
-
|
|
212
|
-
|
|
212
|
+
~/.saptools/cf-hana/backups/YYYYMM/
|
|
213
|
+
<region-org-space-app>-<operation>-<timestamp>.sql
|
|
214
|
+
<region-org-space-app>-<operation>-<timestamp>.statement.sql
|
|
215
|
+
<region-org-space-app>-<operation>-<timestamp>.json
|
|
213
216
|
```
|
|
214
217
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
218
|
+
The main `.sql` backup file contains CSV-formatted rows returned by the derived
|
|
219
|
+
`SELECT`, matching the requested region/org/space/app/action/timestamp naming
|
|
220
|
+
shape. The companion `.statement.sql` file contains the original write statement,
|
|
221
|
+
and `.json` contains non-secret metadata for auditability. Backup files are not
|
|
222
|
+
deleted by `cf-hana`; clean them up manually when they are no longer needed. The
|
|
223
|
+
backup path is printed to stderr so stdout remains parseable.
|
|
219
224
|
|
|
220
225
|
## Safety
|
|
221
226
|
|