Skip to content

fix(db): prevent esbuild from mangling datetime('now') in SQL#68

Closed
wise-toddler wants to merge 1 commit intodebuglebowski:mainfrom
wise-toddler:fix/datetime-double-quotes
Closed

fix(db): prevent esbuild from mangling datetime('now') in SQL#68
wise-toddler wants to merge 1 commit intodebuglebowski:mainfrom
wise-toddler:fix/datetime-double-quotes

Conversation

@wise-toddler
Copy link
Copy Markdown
Contributor

@wise-toddler wise-toddler commented Apr 11, 2026

Summary

  • esbuild converts simple template literals to single-quoted strings, flipping datetime('now') into datetime("now")
  • SQLite treats "now" as a column identifier → crash on startup
  • Changed 2 template literals to double-quoted JS strings so inner single quotes survive the build

Fixes #67

Test plan

  • Verified compiled output no longer contains datetime("now")
  • pnpm build && pnpm start — app launches without SQLite error

Greptile Summary

This PR fixes a startup crash by converting two single-line template literals in handlers-marketplace.ts that contain datetime('now') to double-quoted JS strings, preventing esbuild from swapping the inner single quotes to double quotes during compilation (which caused SQLite to interpret "now" as a column identifier rather than a string literal).

The remaining datetime('now') usages in the same file are all inside genuine multi-line template literals, which esbuild cannot collapse to single-quoted strings, so they are unaffected.

Confidence Score: 5/5

Safe to merge — targeted fix with no logic changes and no remaining P0/P1 issues.

The two changed lines are a straightforward quote style fix; the SQL semantics are identical. The multi-line template literals retaining datetime('now') are unaffected because esbuild cannot represent newline-containing strings as single-quoted literals. Other production files in the codebase already follow the same correct patterns. No P0 or P1 findings.

No files require special attention.

Important Files Changed

Filename Overview
packages/domains/ai-config/src/main/handlers-marketplace.ts Two single-line template literals with datetime('now') converted to double-quoted JS strings (lines 121, 456); remaining datetime('now') usages are in multi-line template literals that esbuild cannot mangle.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Source: template literal with datetime now] --> B{esbuild bundler}
    B -- Before fix single-line --> C[Output: inner single quotes flipped to double quotes]
    B -- After fix double-quoted JS string --> D[Output: inner single quotes preserved]
    C --> E[SQLite treats now as column identifier - CRASH]
    D --> F[SQLite treats now as string literal - OK]
    G[Multi-line template literals lines 342 382 401] --> H{esbuild bundler}
    H --> I[Cannot collapse - contains real newlines - Safe unchanged]
Loading

Reviews (1): Last reviewed commit: "fix(db): use double-quoted strings for S..." | Re-trigger Greptile

(3/5) Reply to the agent's comments like "Can you suggest a fix for this @greptileai?" or ask follow-up questions!

esbuild converts simple template literals to single-quoted strings,
mangling inner datetime('now') into datetime("now"). SQLite treats
double-quoted identifiers as column names, crashing on startup.
@wise-toddler
Copy link
Copy Markdown
Contributor Author

Already fixed in v0.17.2. Closing as duplicate.

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.

v0.17.3: app crashes on startup — datetime("now") SQLite error in seedBuiltinEntries

1 participant