Skip to content

feat(db): gcore:db package — sql-types + sql-sync (MVP) - #8

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

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

Conversation

@godronus

@godronus godronus commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds the gcore:db@0.1.0 package (customer-owned databases bound to an app by name), synchronous SQL for the MVP:

  • deps/db/sql-types.wit: value, column, query-result, statement, db-error, error
  • deps/db/sql-sync.wit: resource database { open(name), query(sql, params), batch(statements) }, blocking
  • world reactor imports gcore:db/sql-sync@0.1.0

Contract is PostgreSQL ($1 placeholders, SQLSTATE codes). Each query auto-commits; each batch is one transaction. Full design and rationale: docs/db/ in G-Core/FastEdge (branch feat/db-interface).

Decisions needed

# Decision Proposal
1 Naming sql-types + sql-sync, following cache-types / cache-sync; the plain name sql is reserved for the async interface (draft PR stacked on this one)
2 Package Separate package gcore:db, not gcore:fastedge, so DB connectors version independently; KV (Upstash) will follow as gcore:db/kv, distinct from Edge Storage key-value
3 value typing Narrowest lossless variant (int8 → int64, numeric → decimal text, json/jsonb → JSON text, bytea → bytes, other types → Postgres text + type-oid)
4 Error variant no-such-database, access-denied, config, connection, timeout, limit, query, internal-error

Merge this first: the engine vendors these files and both SDKs pin this branch as a submodule.

Related: G-Core/FastEdge#659, G-Core/FastEdge-sdk-rust#93, G-Core/FastEdge-sdk-js#155 · Async (stacked): #9

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

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 batch failure contract needs clarification to prevent unsafe retries when the commit outcome is unknown.

1 open issue
What changed in this PR

Adds a synchronous PostgreSQL-compatible database interface and makes it available to components through the reactor world.

Changes:

  • Defines database bindings, parameterized queries, and transactional batches.
  • Adds SQL value types, result metadata, and structured errors.
  • Imports gcore:db/sql@0.1.0 into the reactor world.
File Description
world.wit Imports the new SQL interface.
deps/​db/​sql.wit Defines the database API, types, errors, and behavioral contract.

Review effort: Balanced

Comment thread deps/db/sql.wit Outdated
Comment on lines +92 to +93
/// Returns one `query-result` per statement, in order. On failure nothing is committed
/// and the error of the failing statement is returned.
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