Skip to content

Commit cf5f6d7

Browse files
authored
Merge pull request #884 from Thorium/offline-schema-improvements
Offline mode (ContextSchemaPath) improvements
2 parents 47e33e9 + bbba9a4 commit cf5f6d7

15 files changed

Lines changed: 1343 additions & 166 deletions

‎docs/RELEASE_NOTES.md‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
### 1.5.34 - (unreleased)
2+
- Offline mode (ContextSchemaPath) saves three files beside each other: schema.json for the schema, schema.descriptions.json for table and column descriptions (comments), schema.individuals.json for individuals. Builds read only the schema file; the descriptions file is read for the first tooltip and the individuals file when Individuals are first opened
3+
- Offline tooltips show the saved table and column descriptions, instead of only "Offline mode." SaveContextSchema saves the descriptions of what you hovered over online
4+
- A saved schema no longer carries individuals, so it stays small and loads fast. SaveContextSchema saves the individuals opened so far to the individuals file instead: a table opened again replaces its saved individuals, and the other tables in the file are kept. A schema file with individuals in it still loads them, and re-saving it moves them to the individuals file. Older versions can read the new schema files
5+
- New design-time commands next to SaveContextSchema, online only, that read the whole database instead of what was used so far: SaveContextSchemaFull (every table, column, relationship and stored procedure, and every table and column description) and SaveContextSchemaIndividuals (individuals of every table with a single primary key)
6+
- SaveContextSchemaFull reads the column descriptions of a table in one query instead of one per column (MS SQL Server, PostgreSQL, MySQL, Oracle, Firebird, DuckDB)
7+
- OfflineTools.mergeCacheFiles merges descriptions and individuals files too
8+
- Fix: after a failed SaveContextSchema, design-time commands no longer stop working until the IDE restarts
9+
- Fix: saving individuals no longer fails on a column value such as a DateTimeOffset or an array; such values are saved as text
10+
- Fix: offline individuals with a smallint, bigint or decimal primary key have the key in its own type, as they do online; it came back from the saved file in whatever number type fitted the value
11+
- Fix: individuals of a table with a uuid (PostgreSQL) or uniqueidentifier (MS SQL Server) primary key can be got; getting one failed, as the key was sent as text
12+
- Fix: MySQL, DuckDB and Firebird tables have their columns and relationships in offline mode; they had none, as these databases save the schema under other names than the offline mode looked for
13+
- Fix: MySQL and DuckDB individuals can be got; the query quoted the table name twice, and DuckDB also never got the key
14+
- Fix: DuckDB tables with a foreign key can be used, and have their relationships, the same way round as SQL Server and PostgreSQL have them; opening one failed with "Index was outside the bounds of the array"
15+
- Fix: DuckDB columns of a type with a precision, such as DECIMAL(18,3), are no longer left out
16+
- Fix: DuckDB Owner can list several schemas; no tables were found with more than one
17+
- Fix: DuckDB DATE columns can be read on .NET 6 and later; the driver gives a DateOnly there, and reading it as the DateTime of the column failed
18+
- Fix: DuckDB TIME columns can be read, as a TimeSpan; they were typed DateTime, and reading one always failed
19+
- Fix: DuckDB TIMESTAMP_S, TIMESTAMP_MS, TIMESTAMP_NS and TIMETZ columns are no longer left out
20+
- Fix: tables with a space in their name show their descriptions in tooltips (MS SQL Server, PostgreSQL, Oracle)
21+
- Fix: PostgreSQL tables with capital letters or an apostrophe in their name show their descriptions in tooltips; reading them failed before
22+
- Fix: MS SQL Server descriptions of a table come from its own schema; with tables of the same name in two schemas, either could show the other's
23+
- Fix: Oracle descriptions of tables owned by another schema (Owner) are read; only the current user's tables had them before
24+
125
### 1.5.33 - 19.11.2026
226
- Fix: a saved schema (ContextSchemaPath) loads on both .NET and .NET Framework, whichever saved it. Visual Studio, whose editor and compiler run on .NET Framework, failed on a schema saved by dotnet with "Value cannot be null. Parameter name: key"
327

‎docs/content/core/parameters.fsx‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,49 @@ is saved, the outcome of the method execution is stored in memory so the file wi
160160
In case the database schema changes and the schema file must be updated, remove the outdated file, reload
161161
the solution and retype or uncomment a call to `SaveContextSchema` to regenerate the schema file.
162162
163+
The offline mode uses up to three files beside each other:
164+
165+
| File | Contents | Read |
166+
|---|---|---|
167+
| `schema.json` (`ContextSchemaPath`) | Tables, columns, relationships, stored procedures | Every build |
168+
| `schema.descriptions.json` | Table and column descriptions (comments), shown in tooltips | For the first tooltip |
169+
| `schema.individuals.json` | Sample rows of the [Individuals](individuals.html) feature | When `Individuals` is first opened |
170+
171+
Builds read only the schema file, so descriptions and individuals don't slow them down.
172+
173+
To save the whole database instead of the parts used so far, use these commands while online (before the schema file
174+
exists). Each reads the whole database and may take a while on a large one:
175+
176+
```fsharp
177+
// Every table, column, relationship and stored procedure, to schema.json, and every table
178+
// and column description, to schema.descriptions.json. No rows of data.
179+
ctx.``Design Time Commands``.SaveContextSchemaFull
180+
// IndividualsAmount individuals of every table with a single primary key, to schema.individuals.json
181+
ctx.``Design Time Commands``.SaveContextSchemaIndividuals
182+
```
183+
184+
These two commands exist only while online. Remove the line after saving: once the schema file exists, the
185+
solution is offline and a line that still calls one of them doesn't compile.
186+
187+
Individuals are rows of your data, so mind GDPR/PII before committing the individuals file to version control.
188+
189+
When the database schema changes, remove all three files, not only the schema file, before saving again. The
190+
descriptions and individuals files are otherwise kept as they are, and may then describe tables and columns that
191+
no longer exist.
192+
193+
`SaveContextSchema` also saves the descriptions of the tables and columns you hovered over, and keeps the descriptions
194+
already in the descriptions file. Offline, a table or column whose description wasn't saved shows "Offline mode." in
195+
its tooltip.
196+
197+
Likewise, `SaveContextSchema` saves the individuals of the tables whose `Individuals` you opened to the individuals
198+
file. A table is in the file once: saving it again replaces its individuals, and the other tables already in the file
199+
are kept.
200+
201+
Schema files saved by older versions with individuals in them still work: re-saving such a file moves its individuals
202+
to the individuals file.
203+
163204
There is a tool method FSharp.Data.Sql.Common.OfflineTools.mergeCacheFiles to merge multiple files together.
205+
It merges their descriptions and individuals files as well.
164206
165207
*)
166208

0 commit comments

Comments
 (0)