Skip to content

feat(db): fastedge::db::sql over gcore:db/sql-sync - #93

Closed
godronus wants to merge 6 commits into
mainfrom
feat/db-interface
Closed

godronus wants to merge 6 commits into
mainfrom
feat/db-interface

Conversation

@godronus

@godronus godronus commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

fastedge::db::sql: Rust API for the gcore:db/sql-sync interface (customer-owned Postgres bound to the app by name; Neon first).

  • src/db.rs: re-exports Database, Value, QueryResult, Error, ...; ToSql + params![...] for plain Rust parameters (bool, i32, i64, f64, &str/String, Vec<u8>, Option<T>)
  • With the json feature: QueryAs::query_as::<T>() / rows_as() decode rows into any serde::Deserialize type by column name (non-finite floats stay strings so they fail to decode rather than read as null)
  • src/lib.rs: generate! also generates gcore:db/sql-types + sql-sync
  • wit submodule → G-Core/FastEdge-wit feat/db-interface
  • Example examples/http/wasi/db_sql (wstd), mirrors the JS example (same table, routes, responses)

Calls block (sync interface). Rust stays on sql-sync; the async interface (separate PR in FastEdge-wit / FastEdge / sdk-js) targets JS.

Decisions needed

# Decision Proposal
1 Module path fastedge::db::sql (mirrors gcore:db/sql*); KV later as fastedge::db::kv, apart from fastedge::key_value (Edge Storage)
2 Typed rows Behind the existing json feature (pulls optional serde), not a new feature
3 Async Rust API Not now; possible later on wstd's reactor if the async interface ships

Merge / release

Testing

  • cargo build --all-features; example built for wasm32-wasip2 and run on fastedge-run against Neon (list, by id, 404, missing binding → NoSuchDatabase).

Related: G-Core/FastEdge#659, G-Core/FastEdge-wit#8, G-Core/FastEdge-sdk-js#155

Copilot AI balanced review requested due to automatic review settings October 27, 2026 13:31
@godronus
godronus marked this pull request as draft October 27, 2026 13:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The example’s {} metadata default lacks the required plan field, causing reads of otherwise valid inserts to return 500 errors, and generated documentation for the public API changes is missing.

2 open issues
What changed in this PR

Adds PostgreSQL access to the FastEdge Rust SDK through named database bindings, with credentials managed by the host.

Changes:

  • Exposes fastedge::db::sql, SQL parameter helpers, and typed row decoding behind the json feature.
  • Adds a WASI HTTP example with schema, sample data, and setup instructions.
  • Updates dependencies and records implementation decisions and follow-up work.
File Description
src/​lib.rs Configures SQL bindings and exposes the database module.
src/​db.rs Adds SQL types, parameter conversion, and typed queries.
examples/​README.md Lists the new database example.
examples/​http/​wasi/​db_sql/​src/​lib.rs Demonstrates querying users and returning JSON responses.
examples/​http/​wasi/​db_sql/​schema.sql Defines the example table and seed data.
examples/​http/​wasi/​db_sql/​README.md Documents setup, usage, errors, and build commands.
examples/​http/​wasi/​db_sql/​Cargo.toml Declares the example and its dependencies.
examples/​http/​wasi/​db_sql/​Cargo.lock Locks example dependencies.
context/​CHANGELOG.md Records database integration decisions and follow-ups.
Cargo.toml Adds optional Serde support to the json feature.
Cargo.lock Records the SDK’s direct Serde dependency.

Review effort: Balanced

email text not null unique,
nickname text,
created timestamptz not null default now(),
meta jsonb not null default '{}'
Comment thread src/lib.rs
Comment on lines +415 to +416
/// Customer-owned databases bound to the app by name (`gcore:db`).
pub mod db;
@godronus godronus changed the title Feat/db interface feat(db): fastedge::db::sql over gcore:db/sql-sync Oct 27, 2026
@godronus godronus closed this Oct 30, 2026
@godronus
godronus deleted the feat/db-interface branch October 30, 2026 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants