Skip to content

📝 docs: clarify drizzle raw sql guidance#15467

Merged
tjx666 merged 4 commits into
canaryfrom
docs/drizzle-raw-sql-guidance
Jun 4, 2026
Merged

📝 docs: clarify drizzle raw sql guidance#15467
tjx666 merged 4 commits into
canaryfrom
docs/drizzle-raw-sql-guidance

Conversation

@tjx666

@tjx666 tjx666 commented Jun 4, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • ✨ feat
  • 🐛 fix
  • ♻️ refactor
  • 💄 style
  • 👷 build
  • ⚡️ perf
  • ✅ test
  • 📝 docs
  • 🔨 chore

🔗 Related Issue

N/A

🔀 Description of Change

Clarifies the Drizzle skill guidance for raw SQL refactors:

  • Prefer Drizzle builders when they can preserve the original query shape clearly.
  • Allow expression-level sql<T> inside builders for PostgreSQL-specific expressions.
  • Avoid replacing latency-sensitive single-roundtrip raw SQL with multiple DB queries just to remove execute.
  • Keep recursive CTE raw SQL when Drizzle cannot express it cleanly without performance regression, and tighten it with schema references, user scope, row types, and regression tests.

🧪 How to Test

  • Tested locally
  • Added/updated tests
  • No tests needed

Validated with:

git diff --check

📸 Screenshots / Videos

N/A

📝 Additional Information

Docs-only skill update.

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 4, 2026
@vercel

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Jun 4, 2026 9:50am

Request Review

@sourcery-ai sourcery-ai Bot 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.

We've reviewed this pull request using the Sourcery rules engine

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f91533e776

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .agents/skills/drizzle/SKILL.md Outdated
Comment on lines +184 to +186
Expression-level `sql<T>` is fine inside a Drizzle builder for PostgreSQL features
that do not have a dedicated helper, such as JSON path extraction, casts, aggregate
expressions, `CASE`, `NOW()`, advisory locks, or `FOR UPDATE`.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Use the select lock builder for FOR UPDATE

When a query needs row locking, FOR UPDATE is not an expression-level fragment like CASE or a cast; Drizzle's Postgres select builder exposes a lock clause via .for('update', ...). Leaving it in this list encourages putting sql\FOR UPDATE`` into a select projection/condition, which can generate invalid SQL or skip the intended row lock in latency-sensitive transactional paths.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Addressed in 3e02e74: removed FOR UPDATE from the expression-level sql<T> list and added a .for('update') row-lock example.

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Jun 4, 2026
@tjx666 tjx666 merged commit e165b64 into canary Jun 4, 2026
17 of 18 checks passed
@tjx666 tjx666 deleted the docs/drizzle-raw-sql-guidance branch June 4, 2026 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant