feat: wire Turso/libSQL driver into pnpm dev via TURSO_DATABASE_URL#425
Merged
feat: wire Turso/libSQL driver into pnpm dev via TURSO_DATABASE_URL#425
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…env var Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Enable Turso driver support for local development
feat: wire Turso/libSQL driver into pnpm dev via TURSO_DATABASE_URL
Mar 20, 2026
Contributor
|
@copilot 合并主分支代码并解决冲突 |
…ver-support # Conflicts: # ROADMAP.md # objectstack.config.ts
Contributor
Author
Done — merged |
Contributor
There was a problem hiding this comment.
Pull request overview
Wires the Turso/libSQL driver into the local pnpm dev workflow by selecting the default driver at startup via environment variables, while preserving the existing in-memory default.
Changes:
- Add env-driven
createDefaultDriver()selection (Turso whenTURSO_DATABASE_URLis set; otherwise MemoryDriver) and register asdriver.default. - Add root
.env.exampledocumenting Turso and auth environment variables for local development. - Add
@objectql/driver-tursoto root devDependencies and record the improvement inROADMAP.md.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| objectstack.config.ts | Adds driver-selection factory, registers driver.default, and attempts to connect the chosen driver on startup. |
| .env.example | Documents AUTH_SECRET and Turso env vars / connection modes for dev setup. |
| package.json | Adds @objectql/driver-turso as a workspace devDependency. |
| pnpm-lock.yaml | Locks the new workspace link for @objectql/driver-turso. |
| ROADMAP.md | Notes pnpm dev Turso support as an achievement. |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)
objectstack.config.ts:77
TURSO_SYNC_INTERVALparsing usesNumber(...) || 60, which makes it impossible to configure0(manual-only sync) even though the Turso driver supportsintervalSeconds: 0. Consider parsing the env var so that0is preserved, and only falling back to 60 when the value is missing or NaN.
});
export default {
metadata: {
name: 'objectos',
objectstack.config.ts:111
- The comment says
MemoryDriver has no connect method, butMemoryDriverdoes implementconnect()(as a no-op) for DriverInterface compatibility. Since both TursoDriver and MemoryDriver haveconnect(), you can simplify this block by callingawait defaultDriver.connect()directly (or update the comment/typing accordingly) to avoid redundant runtime checks and casts.
new QueryPlugin({ datasources: { default: defaultDriver } }),
new ValidatorPlugin(),
new FormulaPlugin(),
new ObjectQLSecurityPlugin({
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.
.env.exampleat project root with Turso environment variablesobjectstack.config.tsto conditionally use TursoDriver whenTURSO_DATABASE_URLis set, falling back to MemoryDriver@objectql/driver-tursoas devDependency in rootpackage.jsonROADMAP.mdto reflect this improvementobjectstack.config.ts,ROADMAP.md)Original prompt
Problem
Currently,
pnpm dev(which runsobjectstack serve --dev) usesobjectstack.config.tsthat hardcodesMemoryDriveras the default driver. There is no way to switch to the Turso/libSQL driver for local development without manually editing the config file. The@objectql/driver-tursopackage (v4.2.2) is already implemented with full support for 3 connection modes (Remote Cloud, Local Embedded, Embedded Replica), but it's not wired into the dev workflow.Goal
Enable developers to use the Turso driver during local development via
pnpm devby:.env.examplefile at the project root documenting all Turso-related environment variables.objectstack.config.tsto conditionally use the Turso driver whenTURSO_DATABASE_URLis set in the environment, falling back toMemoryDriverwhen not set (preserving backward compatibility).@objectql/driver-tursoas a devDependency in the rootpackage.json.ROADMAP.mdto reflect this improvement.Implementation Details
1. Create
.env.exampleCreate a
.env.examplefile at the project root with:2. Update
objectstack.config.tsThe config should:
TursoDriverandTursoDriverPluginfrom@objectql/driver-tursoprocess.env.TURSO_DATABASE_URLat startupTursoDriverwith the appropriate config (including optionalauthToken,syncUrl,sync.intervalSeconds)'driver.default'and pass it toQueryPluginMemoryDriverbehavior (zero-config for quick starts)console.log('🗄️ Driver: Turso (file:./data/local.db)')orconsole.log('🗄️ Driver: Memory (in-memory, non-persistent)'))Here's the key pattern for the driver selection in
objectstack.config.ts:The plugin array in the config should also register the driver properly as a service:
3. Update root
package.jsonAdd
@objectql/driver-tursotodevDependencies:4. Update
ROADMAP.mdAdd a line under the existing achievements section:
Key Files to Modify
.env.example(project root)objectstack.config.ts(project root)package.json(project root — add devDependency)ROADMAP.md(project root — update achievements)Constraints
TURSO_DATABASE_URLis set, the system must behave exactly as before (MemoryDriver).TursoDriver/createTursoDriverfactory from@objectql/driver-turso.This pull request was created from Copilot chat.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.