Repository navigation
Conversation
…) + wit-bindgen 0.52.0 bindings
…kept as regression
godronus
marked this pull request as draft
October 27, 2026 13:31
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Silent parameter corruption, result-column loss, incomplete cleanup, and public API mismatches remain unresolved.
3 open issues
1 file not reviewed
pnpm-lock.yaml: Generated file
What changed in this PR
Adds a PostgreSQL database interface to the FastEdge SDK, connecting JavaScript applications to host-managed database bindings.
Changes:
- Introduces SQL runtime builtins, public TypeScript declarations, and module resolution.
- Adds the SQL host interface and generated bindings, with dependency handling for WIT generation.
- Provides a Drizzle example with schema migrations, seed data, and setup instructions.
| File | Description |
|---|---|
types/index.d.ts |
Includes SQL API declarations. |
types/fastedge-db-sql.d.ts |
Defines database, query, result, and error types. |
src/componentize/es-bundle.ts |
Resolves SQL imports to runtime globals. |
runtime/fastedge/scripts/merge-wit-bindings.js |
Hoists nested WIT dependencies. |
runtime/fastedge/host-api/wit/deps/fastedge/world.wit |
Imports the SQL host interface. |
runtime/fastedge/host-api/wit/deps/db/sql.wit |
Defines the PostgreSQL host contract. |
runtime/fastedge/host-api/bindings/bindings.h |
Adds SQL binding declarations. |
runtime/fastedge/host-api/bindings/bindings.c |
Adds SQL calls and cleanup helpers. |
runtime/fastedge/CMakeLists.txt |
Registers the SQL builtin. |
runtime/fastedge/builtins/db-sql.h |
Declares builtin database methods. |
runtime/fastedge/builtins/db-sql.cpp |
Implements SQL operations and value conversion. |
pnpm-lock.yaml |
Records database example dependencies. |
examples/README.md |
Lists the SQL example. |
examples/db-sql/tsconfig.json |
Configures example TypeScript checking. |
examples/db-sql/src/schema.ts |
Defines the example users table. |
examples/db-sql/src/index.ts |
Serves user queries over HTTP. |
examples/db-sql/src/db.ts |
Adapts SQL queries to Drizzle. |
examples/db-sql/README.md |
Documents setup, usage, and limitations. |
examples/db-sql/package.json |
Declares dependencies and example commands. |
examples/db-sql/drizzle/meta/0001_snapshot.json |
Records schema state after seeding. |
examples/db-sql/drizzle/meta/0000_snapshot.json |
Records the initial schema state. |
examples/db-sql/drizzle/meta/_journal.json |
Tracks migration order. |
examples/db-sql/drizzle/0001_seed.sql |
Inserts sample users. |
examples/db-sql/drizzle/0000_init.sql |
Creates the users table. |
examples/db-sql/drizzle.config.ts |
Configures external database migrations. |
examples/db-sql/.fastedge/build-config.js |
Configures the example WASM build. |
context/CHANGELOG.md |
Records the SQL proof of concept. |
Review effort: Balanced
Comment on lines
+150
to
+153
| if (v.isBigInt()) { | ||
| out.tag = GCORE_DB_SQL_VALUE_INT64; | ||
| out.val.int64 = JS::ToBigInt64(v.toBigInt()); | ||
| return true; |
Comment on lines
1135
to
1137
| void wasi_io_streams_result_list_u8_stream_error_free(wasi_io_streams_result_list_u8_stream_error_t *ptr) { | ||
| if (!ptr->is_err) { | ||
| bindings_list_u8_free(&ptr->val.ok); | ||
| } else { |
| for (size_t j = 0; j < row.len && j < names.length(); j++) { | ||
| if (!from_value(cx, row.ptr[j], &cell)) return nullptr; | ||
| if (array_mode ? !JS_SetElement(cx, out, j, cell) | ||
| : !JS_SetPropertyById(cx, out, names[j], cell)) { |
…es-bundle re-exports only
…tions, mirrors the Rust db_sql example
…al db error strings
godronus
force-pushed
the
feat/db-interface
branch
from
October 27, 2026 15:00
fed0058 to
2d5086c
Compare
…served for async)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
fastedge::db/sql: JS API for customer-owned Postgres bound to the app by name (Neon first), overgcore:db/sql-sync.runtime/fastedge/builtins/db-sql.{h,cpp}:SqlDatabase.open(name),query(sql, params?, { rowMode? }),batch(statements, { rowMode? })returning Promises;SqlErroris a realError(kind, SQLSTATEcode,detail,hint,constraint)int8/numeric→ string (no precision loss),json/jsonbparsed,bytea→Uint8Array,rowMode: 'array'; params acceptbigint,Uint8Array,Date, objects (JSON)types/fastedge-db-sql.d.ts;merge-wit-bindings.jshoists FastEdge-wit's owndeps/intowit/deps/examples/db-sql: Drizzle ORM viadrizzle-orm/pg-proxy(recipe, no wrapper package), drizzle-kit migrations; mirrors the Rust exampleruntime/FastEdge-wit→ G-Core/FastEdge-witfeat/db-interfaceStacked on #156 (StarlingMonkey v0.4.0, wit-bindgen 0.52): this PR shows those commits until #156 merges.
Decisions needed
queryreturns an already-settled Promise andPromise.allruns in series. Async version (stacked draft PR) makes queries concurrent:Promise.allof 3 = 319 ms vs 617 ms, no single-query cost. Recommendation: ship JS on asyncgcore:db(the world includes it), even without using a database; hosts without it fail with530 context error(also breakscross-platform-build.test.jscomponent-import tests against the currentfastedge-test). Release only after: engine on all edges →@gcoredev/fastedge-testupdated@gcoredev/fastedge-drizzlepackage (drizzle-orm Apache-2.0, drizzle-kit MIT)Testing
fastedge-runagainst Neon (list, by id, 404, SQLSTATE42P01→SqlErrorkind: 'query').Related: G-Core/FastEdge#659, G-Core/FastEdge-wit#8, G-Core/FastEdge-sdk-rust#93 · Async (stacked): #157