Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,9 @@
"create-payload-app": "workspace:*",
"cross-env": "7.0.3",
"dotenv": "16.4.7",
"drizzle-kit": "0.28.0",
"drizzle-kit": "0.31.0",
"drizzle-orm": "0.43.1",
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.

Interesting that this was not here before.

"escape-html": "^1.0.3",
"execa": "5.1.1",
"form-data": "3.0.1",
"fs-extra": "10.1.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/db-postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"@payloadcms/drizzle": "workspace:*",
"@types/pg": "8.10.2",
"console-table-printer": "2.12.1",
"drizzle-kit": "0.28.0",
"drizzle-orm": "0.36.1",
"drizzle-kit": "0.31.1",
"drizzle-orm": "0.44.2",
"pg": "8.11.3",
"prompts": "2.4.2",
"to-snake-case": "1.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/db-sqlite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@
"@libsql/client": "0.14.0",
"@payloadcms/drizzle": "workspace:*",
"console-table-printer": "2.12.1",
"drizzle-kit": "0.28.0",
"drizzle-orm": "0.36.1",
"drizzle-kit": "0.31.1",
"drizzle-orm": "0.44.2",
"prompts": "2.4.2",
"to-snake-case": "1.0.0",
"uuid": "9.0.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/db-vercel-postgres/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
"@payloadcms/drizzle": "workspace:*",
"@vercel/postgres": "^0.9.0",
"console-table-printer": "2.12.1",
"drizzle-kit": "0.28.0",
"drizzle-orm": "0.36.1",
"drizzle-kit": "0.31.1",
"drizzle-orm": "0.44.2",
"pg": "8.11.3",
"prompts": "2.4.2",
"to-snake-case": "1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/drizzle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"dependencies": {
"console-table-printer": "2.12.1",
"dequal": "2.0.3",
"drizzle-orm": "0.36.1",
"drizzle-orm": "0.44.2",
"prompts": "2.4.2",
"to-snake-case": "1.0.0",
"uuid": "9.0.0"
Expand Down
10 changes: 9 additions & 1 deletion packages/drizzle/src/transform/read/hasManyNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,21 @@ export const transformHasManyNumber = ({
if (withinArrayOrBlockLocale) {
result = numberRows.reduce((acc, { locale, number }) => {
if (locale === withinArrayOrBlockLocale) {
if (typeof number === 'string') {
number = Number(number)
}
acc.push(number)
}

return acc
}, [])
} else {
result = numberRows.map(({ number }) => number)
result = numberRows.map(({ number }) => {
if (typeof number === 'string') {
number = Number(number)
}
return number
})
}

if (locale) {
Expand Down
8 changes: 7 additions & 1 deletion packages/drizzle/src/upsertRow/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,9 +379,15 @@ export const upsertRow = async <T extends Record<string, unknown> | TypeWithID>(
// //////////////////////////////////
// Error Handling
// //////////////////////////////////
} catch (error) {
} catch (caughtError) {
// Unique constraint violation error
// '23505' is the code for PostgreSQL, and 'SQLITE_CONSTRAINT_UNIQUE' is for SQLite

let error = caughtError
if (typeof caughtError === 'object' && 'cause' in caughtError) {
error = caughtError.cause
}

if (error.code === '23505' || error.code === 'SQLITE_CONSTRAINT_UNIQUE') {
let fieldName: null | string = null
// We need to try and find the right constraint for the field but if we can't we fallback to a generic message
Expand Down
Loading
Loading