@payloadcms/drizzle 3.90.2 → 3.91.0-internal.07e4582
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/sqlite/insert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../../src/sqlite/insert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,MAAM,EAAE,MAAM,YAAY,CAAA;AAE3D,eAAO,MAAM,MAAM,EAAE,MAoCpB,CAAA"}
|
package/dist/sqlite/insert.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
+
import { getTableColumns } from 'drizzle-orm';
|
|
1
2
|
export const insert = async function({ db, onConflictDoUpdate, tableName, values }) {
|
|
2
3
|
const table = this.tables[tableName];
|
|
3
4
|
// Batch insert if limitedBoundParameters: true
|
|
4
5
|
if (this.limitedBoundParameters && Array.isArray(values)) {
|
|
5
6
|
const results = [];
|
|
6
|
-
|
|
7
|
+
// Drizzle emits a value for every table column per row, not just the keys present on the row —
|
|
8
|
+
// omitted columns fall back to their default / defaultFn, which is also a bound parameter
|
|
9
|
+
const colsPerRow = Math.max(1, Object.keys(getTableColumns(table)).length);
|
|
7
10
|
const maxParams = 100;
|
|
8
11
|
const maxRowsPerBatch = Math.max(1, Math.floor(maxParams / colsPerRow));
|
|
9
12
|
for(let i = 0; i < values.length; i += maxRowsPerBatch){
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/sqlite/insert.ts"],"sourcesContent":["import type { BaseSQLiteAdapter, Insert } from './types.js'\n\nexport const insert: Insert = async function (\n // Here 'this' is not a parameter. See:\n // https://www.typescriptlang.org/docs/handbook/2/classes.html#this-parameters\n this: BaseSQLiteAdapter,\n { db, onConflictDoUpdate, tableName, values },\n): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n\n // Batch insert if limitedBoundParameters: true\n if (this.limitedBoundParameters && Array.isArray(values)) {\n const results: Record<string, unknown>[] = []\n const colsPerRow = Object.keys(
|
|
1
|
+
{"version":3,"sources":["../../src/sqlite/insert.ts"],"sourcesContent":["import { getTableColumns } from 'drizzle-orm'\n\nimport type { BaseSQLiteAdapter, Insert } from './types.js'\n\nexport const insert: Insert = async function (\n // Here 'this' is not a parameter. See:\n // https://www.typescriptlang.org/docs/handbook/2/classes.html#this-parameters\n this: BaseSQLiteAdapter,\n { db, onConflictDoUpdate, tableName, values },\n): Promise<Record<string, unknown>[]> {\n const table = this.tables[tableName]\n\n // Batch insert if limitedBoundParameters: true\n if (this.limitedBoundParameters && Array.isArray(values)) {\n const results: Record<string, unknown>[] = []\n // Drizzle emits a value for every table column per row, not just the keys present on the row —\n // omitted columns fall back to their default / defaultFn, which is also a bound parameter\n const colsPerRow = Math.max(1, Object.keys(getTableColumns(table)).length)\n const maxParams = 100\n const maxRowsPerBatch = Math.max(1, Math.floor(maxParams / colsPerRow))\n\n for (let i = 0; i < values.length; i += maxRowsPerBatch) {\n const batch = values.slice(i, i + maxRowsPerBatch)\n\n const batchResult = onConflictDoUpdate\n ? await db.insert(table).values(batch).onConflictDoUpdate(onConflictDoUpdate).returning()\n : await db.insert(table).values(batch).returning()\n\n results.push(...(batchResult as Record<string, unknown>[]))\n }\n\n return results\n }\n\n const result = onConflictDoUpdate\n ? await db.insert(table).values(values).onConflictDoUpdate(onConflictDoUpdate).returning()\n : await db.insert(table).values(values).returning()\n\n // See https://github.com/payloadcms/payload/pull/11831#discussion_r2010431908\n return result as Record<string, unknown>[]\n}\n"],"names":["getTableColumns","insert","db","onConflictDoUpdate","tableName","values","table","tables","limitedBoundParameters","Array","isArray","results","colsPerRow","Math","max","Object","keys","length","maxParams","maxRowsPerBatch","floor","i","batch","slice","batchResult","returning","push","result"],"mappings":"AAAA,SAASA,eAAe,QAAQ,cAAa;AAI7C,OAAO,MAAMC,SAAiB,eAI5B,EAAEC,EAAE,EAAEC,kBAAkB,EAAEC,SAAS,EAAEC,MAAM,EAAE;IAE7C,MAAMC,QAAQ,IAAI,CAACC,MAAM,CAACH,UAAU;IAEpC,+CAA+C;IAC/C,IAAI,IAAI,CAACI,sBAAsB,IAAIC,MAAMC,OAAO,CAACL,SAAS;QACxD,MAAMM,UAAqC,EAAE;QAC7C,+FAA+F;QAC/F,0FAA0F;QAC1F,MAAMC,aAAaC,KAAKC,GAAG,CAAC,GAAGC,OAAOC,IAAI,CAAChB,gBAAgBM,QAAQW,MAAM;QACzE,MAAMC,YAAY;QAClB,MAAMC,kBAAkBN,KAAKC,GAAG,CAAC,GAAGD,KAAKO,KAAK,CAACF,YAAYN;QAE3D,IAAK,IAAIS,IAAI,GAAGA,IAAIhB,OAAOY,MAAM,EAAEI,KAAKF,gBAAiB;YACvD,MAAMG,QAAQjB,OAAOkB,KAAK,CAACF,GAAGA,IAAIF;YAElC,MAAMK,cAAcrB,qBAChB,MAAMD,GAAGD,MAAM,CAACK,OAAOD,MAAM,CAACiB,OAAOnB,kBAAkB,CAACA,oBAAoBsB,SAAS,KACrF,MAAMvB,GAAGD,MAAM,CAACK,OAAOD,MAAM,CAACiB,OAAOG,SAAS;YAElDd,QAAQe,IAAI,IAAKF;QACnB;QAEA,OAAOb;IACT;IAEA,MAAMgB,SAASxB,qBACX,MAAMD,GAAGD,MAAM,CAACK,OAAOD,MAAM,CAACA,QAAQF,kBAAkB,CAACA,oBAAoBsB,SAAS,KACtF,MAAMvB,GAAGD,MAAM,CAACK,OAAOD,MAAM,CAACA,QAAQoB,SAAS;IAEnD,8EAA8E;IAC9E,OAAOE;AACT,EAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/drizzle",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.91.0-internal.07e4582",
|
|
4
4
|
"description": "A library of shared functions used by different payload database adapters",
|
|
5
5
|
"homepage": "https://payloadcms.com",
|
|
6
6
|
"repository": {
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"@types/pg": "8.20.0",
|
|
61
61
|
"@types/to-snake-case": "1.0.0",
|
|
62
62
|
"@payloadcms/eslint-config": "3.28.0",
|
|
63
|
-
"payload": "3.
|
|
63
|
+
"payload": "3.91.0-internal.07e4582"
|
|
64
64
|
},
|
|
65
65
|
"peerDependencies": {
|
|
66
|
-
"payload": "3.
|
|
66
|
+
"payload": "3.91.0-internal.07e4582"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "pnpm build:swc && pnpm build:types",
|