fix(docs): correct MSSQL insert output() call order#660
Open
sleitor wants to merge 1 commit intodrizzle-team:mainfrom
Open
fix(docs): correct MSSQL insert output() call order#660sleitor wants to merge 1 commit intodrizzle-team:mainfrom
sleitor wants to merge 1 commit intodrizzle-team:mainfrom
Conversation
Per MSSQL SQL syntax, OUTPUT clause comes before VALUES.
The correct Drizzle API is:
db.insert(users).output().values({ name: 'Dan' })
not .values(...).output().
Fixes drizzle-team/drizzle-orm#5472
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
Fixes drizzle-team/drizzle-orm#5472
The
insert.mdxdocs show.output()called after.values(), which throws a runtime error. Per MSSQL SQL syntax (and the Drizzle API implementation),OUTPUTmust come beforeVALUES:This is confirmed by maintainer @AleksandrSherman: "The use of the
outputclause in mssql is based directly on the official mssql documentation... But it seems that docs have an incorrect example. We will update that."Changes
Before:
After:
Also corrected the description which incorrectly said "PostgreSQL and SQLite" instead of "MSSQL".