Skip to content

Commit 8277e8f

Browse files
committed
Rust update
1 parent 3a5e111 commit 8277e8f

4 files changed

Lines changed: 293 additions & 295 deletions

File tree

‎README.md‎

Lines changed: 14 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Typed SQL for F#, from one source, on .NET **and** through Fable to **Rust**,
44
**JavaScript NodeJs** and **Erlang/BEAM**.
55

6-
NOTE: Rust is "coming soon" as it needs some Fable side PRs merged first.
6+
NOTE: Rust needs a Fable newer than 5.15 — the fixes are merged on Fable's main branch, awaiting release.
77

88
Point the generator at your database, get a module per table with typed columns
99
and row mappers, and write queries against them:
@@ -57,26 +57,20 @@ value you supply is a bound parameter, never concatenated into the statement.
5757
| .NET | ADO.NET (any `DbConnection`) | nothing | full suite, over `Microsoft.Data.Sqlite` |
5858
| JavaScript | `node:sqlite` (Node 22.5+) | Fable 5.15 | full suite |
5959
| Erlang / BEAM | *none yet* | Fable 5.15 | everything except the driver |
60-
| Rust | sqlx + SQLite (bundled) | **unreleased Fable**, see below | full suite |
61-
| Rust | sqlx + **PostgreSQL** | **unreleased Fable**, see below | full suite, against PostgreSQL 18 |
62-
| Rust | sqlx + MySQL / MariaDB | **unreleased Fable**, see below | compiles and connects; **not run against a server** |
60+
| Rust | sqlx + SQLite (bundled) | Fable built from `main` (see below) | full suite |
61+
| Rust | sqlx + **PostgreSQL** | Fable built from `main` (see below) | full suite, against PostgreSQL 18 |
62+
| Rust | sqlx + MySQL / MariaDB | Fable built from `main` (see below) | compiles and connects; **not run against a server** |
6363

6464
**.NET, JavaScript and BEAM work on released Fable today** — all three were run
6565
against Fable 5.15.0 from NuGet, not a local build.
6666

67-
**Rust needs a Fable fix that has not shipped yet.** Two independent reasons,
68-
both in the Rust async runtime:
69-
70-
- The async computation builder has no `Combine`, so `Db.submit` and
71-
`Db.inTransaction` -- which use a `for` loop and a `try/with` inside an
72-
`async` block -- fail to compile with *no `singleton` in `AsyncBuilder_`*.
73-
- Awaiting a task sleeps 100 ms per poll, which measured 2718 ms for 65 ms of
74-
real work. Every query would pay it.
75-
76-
Both are fixed by the `fix/rust-async` branch in
77-
[fable-compiler/Fable](https://github.com/fable-compiler/Fable). Until it is
78-
merged and released, build Fable from that branch and point `FABLE_LOCAL_DLL`
79-
at it; see [GAPS.md](GAPS.md).
67+
**Rust works on Fable's `main` branch; the release carrying it is pending.**
68+
The fixes it needed — the async builder's `Combine`, the async runtime's
69+
polling overhead, exception and type-test codegen, string enumeration — are
70+
all merged into [fable-compiler/Fable](https://github.com/fable-compiler/Fable)
71+
(PRs #4916–#4918, #4920, #4921), and the full suite passes against a compiler
72+
built from unmodified `main`. Until the next Fable release ships, build Fable
73+
from `main` and point `FABLE_LOCAL_DLL` at it; see [GAPS.md](GAPS.md).
8074

8175
The three Rust backends are one code path — sqlx's `Any` driver picks the engine
8276
from the URL — so they differ only in connection string, placeholder syntax and
@@ -110,9 +104,9 @@ The packages carry their F# sources under `fable/`, the way Fable libraries do,
110104
so a Fable project compiles the library to its own target while .NET uses the
111105
compiled assembly from the same package.
112106

113-
JavaScript and BEAM need nothing beyond released Fable. Rust additionally needs
114-
the unmerged fix described under [Status](#status), and the consuming crate's
115-
`Cargo.toml` needs the driver stack the connector calls into:
107+
JavaScript and BEAM need nothing beyond released Fable. Rust needs a Fable
108+
built from `main` until the next release ships (see [Status](#status)), and the
109+
consuming crate's `Cargo.toml` needs the driver stack the connector calls into:
116110

117111
```toml
118112
[dependencies]

‎tests/SQLProvider.Fable.SmokeTests/GeneratedSchema.fs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ module Orders =
7676
let Freight = Col.decimal table "Freight"
7777

7878
/// One row, as a record.
79-
[<Struct>]
8079
type Row =
8180
{ OrderId: int64
8281
CustomerId: int64

‎tests/SQLProvider.Fable.SmokeTests/Harness.fs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,11 @@ let fail name detail =
2020
Passed = false
2121
Detail = detail }
2222

23-
let check name expected actual =
23+
// The parameters are annotated on purpose: everything is compared as text by
24+
// design, and without the annotation the interpolation below leaves this
25+
// generic -- which .NET accepts and the Rust target cannot format (no Display
26+
// on a bare type parameter).
27+
let check name (expected: string) (actual: string) =
2428
if expected = actual then
2529
pass name
2630
else

0 commit comments

Comments
 (0)