{ "reward": 1.0, "done": true, "content": null, "info": { "diff_stat": { "files": [ "packages/core/src/model.js", "packages/core/test/integration/model/bulk-create/ignore-duplicates.test.ts" ], "added": 444, "removed": 1 }, "graded_diff": "diff --git a/packages/core/src/model.js b/packages/core/src/model.js\nindex cb25a684a..da84d6840 100644\n--- a/packages/core/src/model.js\n+++ b/packages/core/src/model.js\n@@ -2327,6 +2327,10 @@ ${associationOwner._getAssociationDebugList()}`);\n \n const modelDefinition = model.modelDefinition;\n \n+ // Instances whose row the database skipped (ignoreDuplicates). They are\n+ // left as the caller built them: unsaved, and carrying no other row's values.\n+ const skipped = new Set();\n+\n options.fields = options.fields || Array.from(modelDefinition.attributes.keys());\n const createdAtAttr = modelDefinition.timestampAttributeNames.createdAt;\n const updatedAtAttr = modelDefinition.timestampAttributeNames.updatedAt;\n@@ -2497,6 +2501,21 @@ ${associationOwner._getAssociationDebugList()}`);\n );\n }\n \n+ // With ignoreDuplicates, a RETURNING dialect only hands back the rows\n+ // it actually inserted, so the returned rows cannot be matched to the\n+ // records by position. They are matched on the model's candidate keys\n+ // instead; make sure those columns come back even when the caller\n+ // restricted the returning list.\n+ const identityKeys =\n+ options.ignoreDuplicates &&\n+ options.returning &&\n+ model.sequelize.dialect.supports.returnValues\n+ ? model._bulkCreateIdentityKeys()\n+ : null;\n+ if (identityKeys && Array.isArray(options.returning)) {\n+ options.returning = uniq([...options.returning, ...identityKeys.flat()]);\n+ }\n+\n const results = await model.queryInterface.bulkInsert(\n model.table,\n records,\n@@ -2504,9 +2523,17 @@ ${associationOwner._getAssociationDebugList()}`);\n fieldMappedAttributes,\n );\n if (Array.isArray(results)) {\n- for (const [i, result] of results.entries()) {\n+ const resultForInstance = identityKeys\n+ ? model._matchReturnedRows(instances, records, results, identityKeys, skipped)\n+ : results;\n+\n+ for (const [i, result] of resultForInstance.entries()) {\n const instance = instances[i];\n \n+ if (!result) {\n+ continue;\n+ }\n+\n for (const key in result) {\n if (!Object.hasOwn(result, key)) {\n continue;\n@@ -2555,6 +2582,12 @@ ${associationOwner._getAssociationDebugList()}`);\n const associationInstanceIndexToInstanceMap = [];\n \n for (const instance of instances) {\n+ if (skipped.has(instance)) {\n+ // the parent row was not created by this call, so its key\n+ // is unknown; its children must not be stored under it\n+ continue;\n+ }\n+\n let associated = instance.get(include.as);\n if (!Array.isArray(associated)) {\n associated = [associated];\n@@ -2660,6 +2693,20 @@ ${associationOwner._getAssociationDebugList()}`);\n \n // map fields back to attributes\n for (const instance of instances) {\n+ if (skipped.has(instance)) {\n+ // the timestamps this call filled in were never stored for a\n+ // skipped record; drop them so the instance shows only its own state\n+ if (createdAtAttr && instance.dataValues[createdAtAttr] === now) {\n+ delete instance.dataValues[createdAtAttr];\n+ }\n+\n+ if (updatedAtAttr && instance.dataValues[updatedAtAttr] === now) {\n+ delete instance.dataValues[updatedAtAttr];\n+ }\n+\n+ continue;\n+ }\n+\n const attributeDefs = modelDefinition.attributes;\n \n for (const attribute of attributeDefs.values()) {\n@@ -2692,6 +2739,165 @@ ${associationOwner._getAssociationDebugList()}`);\n return await recursiveBulkCreate(instances, options);\n }\n \n+ /**\n+ * The column sets a returned row can be identified by: the primary key and\n+ * every non-partial unique index. Used by {@link Model.bulkCreate} to match\n+ * the rows a RETURNING dialect hands back to the records that were sent\n+ * when `ignoreDuplicates` may have skipped some of them.\n+ *\n+ * @returns {string[][]} column names, one array per candidate key\n+ * @private\n+ */\n+ static _bulkCreateIdentityKeys() {\n+ const keys = [];\n+ const seen = new Set();\n+ const add = columns => {\n+ const normalized = columns.map(column => (typeof column === 'string' ? column : column.name));\n+ const id = normalized.join('\\0');\n+ if (normalized.length > 0 && !seen.has(id)) {\n+ seen.add(id);\n+ keys.push(normalized);\n+ }\n+ };\n+\n+ add(Object.values(this.primaryKeys).map(attribute => attribute.field));\n+ for (const index of this.getIndexes()) {\n+ if (index.unique && !index.where && index.fields) {\n+ add(index.fields);\n+ }\n+ }\n+\n+ return keys;\n+ }\n+\n+ /**\n+ * Pairs the rows returned by a bulk INSERT with the records that produced\n+ * them. A row belongs to the first not-yet-paired record that agrees with\n+ * it on one of the candidate keys; the row order is never relied on.\n+ * Records that no row matches were skipped by the database and are added\n+ * to `skipped`. Refuses to guess: if a returned row cannot be attributed\n+ * to any record, an error is thrown rather than assigning it by position.\n+ *\n+ * @param {Model[]} instances the instances, in record order\n+ * @param {object[]} records the column-keyed values sent for each instance\n+ * @param {object[]} results the rows the database returned\n+ * @param {string[][]} identityKeys from {@link Model._bulkCreateIdentityKeys}\n+ * @param {Set} skipped receives the instances whose row was not inserted\n+ * @returns {Array} the matching row for each instance, or null\n+ * @private\n+ */\n+ static _matchReturnedRows(instances, records, results, identityKeys, skipped) {\n+ const modelDefinition = this.modelDefinition;\n+\n+ const normalize = value => {\n+ if (value instanceof Date) {\n+ return value.toISOString();\n+ }\n+\n+ if (Buffer.isBuffer(value)) {\n+ return value.toString('hex');\n+ }\n+\n+ return String(value);\n+ };\n+\n+ const parseRow = row => {\n+ const out = pojo();\n+ for (const column of Object.keys(row)) {\n+ const attribute = modelDefinition.columns.get(column);\n+ out[column] =\n+ row[column] != null && attribute?.type instanceof AbstractDataType\n+ ? attribute.type.parseDatabaseValue(row[column])\n+ : row[column];\n+ }\n+\n+ return out;\n+ };\n+\n+ // every key signature a column-keyed value set can be identified by\n+ const signaturesOf = values => {\n+ const signatures = [];\n+ for (const [k, key] of identityKeys.entries()) {\n+ const parts = [];\n+ for (const column of key) {\n+ if (values[column] == null) {\n+ parts.length = 0;\n+ break;\n+ }\n+\n+ parts.push(normalize(values[column]));\n+ }\n+\n+ if (parts.length > 0) {\n+ signatures.push(`${k}:${parts.join('\\0')}`);\n+ }\n+ }\n+\n+ return signatures;\n+ };\n+\n+ const rowsBySignature = new Map();\n+ const unpaired = new Set(results);\n+ for (const row of results) {\n+ for (const signature of signaturesOf(parseRow(row))) {\n+ if (!rowsBySignature.has(signature)) {\n+ rowsBySignature.set(signature, []);\n+ }\n+\n+ rowsBySignature.get(signature).push(row);\n+ }\n+ }\n+\n+ const paired = instances.map(() => null);\n+ const withoutKey = [];\n+ for (const [i, instance] of instances.entries()) {\n+ const signatures = signaturesOf(records[i]);\n+ if (signatures.length === 0) {\n+ withoutKey.push(i);\n+ continue;\n+ }\n+\n+ for (const signature of signatures) {\n+ const row = (rowsBySignature.get(signature) ?? []).find(candidate =>\n+ unpaired.has(candidate),\n+ );\n+ if (row) {\n+ paired[i] = row;\n+ unpaired.delete(row);\n+ break;\n+ }\n+ }\n+\n+ if (!paired[i]) {\n+ skipped.add(instance);\n+ }\n+ }\n+\n+ // Records that carry no value for any candidate key cannot have\n+ // conflicted, so the leftover rows are theirs, provided the counts agree.\n+ if (withoutKey.length > 0) {\n+ if (unpaired.size !== withoutKey.length) {\n+ throw new Error(\n+ `bulkCreate could not attribute the rows returned by the database to the records: ${unpaired.size} returned row(s) left for ${withoutKey.length} record(s) without a key value.`,\n+ );\n+ }\n+\n+ const leftovers = results.filter(row => unpaired.has(row));\n+ for (const [j, i] of withoutKey.entries()) {\n+ paired[i] = leftovers[j];\n+ unpaired.delete(leftovers[j]);\n+ }\n+ }\n+\n+ if (unpaired.size > 0) {\n+ throw new Error(\n+ `bulkCreate could not attribute ${unpaired.size} row(s) returned by the database to any record. Every candidate key column must be part of the returned columns.`,\n+ );\n+ }\n+\n+ return paired;\n+ }\n+\n /**\n * Truncates the table associated with the model.\n *\ndiff --git a/packages/core/test/integration/model/bulk-create/ignore-duplicates.test.ts b/packages/core/test/integration/model/bulk-create/ignore-duplicates.test.ts\nnew file mode 100644\nindex 000000000..69e8c1ab8\n--- /dev/null\n+++ b/packages/core/test/integration/model/bulk-create/ignore-duplicates.test.ts\n@@ -0,0 +1,237 @@\n+import type {\n+ CreationOptional,\n+ InferAttributes,\n+ InferCreationAttributes,\n+ NonAttribute,\n+} from '@sequelize/core';\n+import { DataTypes, Model } from '@sequelize/core';\n+import { expect } from 'chai';\n+import { beforeAll2, sequelize, setResetMode } from '../../support';\n+\n+const dialect = sequelize.dialect;\n+\n+// With ignoreDuplicates, a RETURNING dialect only returns the rows it actually\n+// inserted. The instances bulkCreate returns must still line up with the\n+// records that were passed in.\n+describe('Model.bulkCreate with ignoreDuplicates on a RETURNING dialect', () => {\n+ if (\n+ !dialect.supports.returnValues ||\n+ !(dialect.supports.inserts.ignoreDuplicates || dialect.supports.inserts.onConflictDoNothing)\n+ ) {\n+ return;\n+ }\n+\n+ setResetMode('destroy');\n+\n+ const vars = beforeAll2(async () => {\n+ class User extends Model, InferCreationAttributes> {\n+ declare id: CreationOptional;\n+ declare uniqueName: string;\n+ declare secretValue: string | null;\n+ declare createdAt: CreationOptional;\n+ declare updatedAt: CreationOptional;\n+ declare tasks?: NonAttribute;\n+ }\n+\n+ class Task extends Model, InferCreationAttributes> {\n+ declare id: CreationOptional;\n+ declare title: string;\n+ declare userId: CreationOptional;\n+ }\n+\n+ class Seat extends Model, InferCreationAttributes> {\n+ declare id: CreationOptional;\n+ declare room: string;\n+ declare number: number;\n+ declare label: string | null;\n+ }\n+\n+ class Code extends Model, InferCreationAttributes> {\n+ declare code: string;\n+ declare label: string | null;\n+ }\n+\n+ User.init(\n+ {\n+ id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },\n+ uniqueName: { type: DataTypes.STRING, unique: true, allowNull: false },\n+ secretValue: DataTypes.STRING,\n+ },\n+ { sequelize },\n+ );\n+ Task.init(\n+ {\n+ id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },\n+ title: { type: DataTypes.STRING, allowNull: false },\n+ },\n+ { sequelize },\n+ );\n+ Seat.init(\n+ {\n+ id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },\n+ room: { type: DataTypes.STRING, allowNull: false },\n+ number: { type: DataTypes.INTEGER, allowNull: false },\n+ label: DataTypes.STRING,\n+ },\n+ { sequelize, indexes: [{ unique: true, fields: ['room', 'number'] }] },\n+ );\n+ Code.init(\n+ {\n+ code: { type: DataTypes.STRING, primaryKey: true },\n+ label: DataTypes.STRING,\n+ },\n+ { sequelize },\n+ );\n+\n+ User.hasMany(Task, { as: 'tasks', foreignKey: 'userId' });\n+\n+ await sequelize.sync({ force: true });\n+\n+ return { User, Task, Seat, Code };\n+ });\n+\n+ it('assigns each returned row to its own record when some records are skipped', async () => {\n+ const { User } = vars;\n+ await User.bulkCreate([\n+ { uniqueName: 'Peter', secretValue: '42' },\n+ { uniqueName: 'Paul', secretValue: '23' },\n+ ]);\n+\n+ const statements: string[] = [];\n+ const result = await User.bulkCreate(\n+ [\n+ { uniqueName: 'Peter', secretValue: 'dup' },\n+ { uniqueName: 'Michael', secretValue: '26' },\n+ { uniqueName: 'Paul', secretValue: 'dup' },\n+ { uniqueName: 'Anna', secretValue: '27' },\n+ ],\n+ { ignoreDuplicates: true, logging: sql => statements.push(sql) },\n+ );\n+\n+ expect(statements).to.have.length(1);\n+ expect(result.map(user => user.uniqueName)).to.deep.equal(['Peter', 'Michael', 'Paul', 'Anna']);\n+\n+ const rows = await User.findAll({ order: ['id'], raw: true });\n+ expect(rows.map(row => row.uniqueName)).to.deep.equal(['Peter', 'Paul', 'Michael', 'Anna']);\n+\n+ const byName = new Map(rows.map(row => [row.uniqueName, row]));\n+ for (const inserted of [result[1], result[3]]) {\n+ expect(inserted.isNewRecord).to.equal(false);\n+ expect(inserted.id).to.equal(byName.get(inserted.uniqueName)!.id);\n+ expect(inserted.secretValue).to.equal(byName.get(inserted.uniqueName)!.secretValue);\n+ expect(inserted.changed()).to.equal(false);\n+ }\n+\n+ for (const skipped of [result[0], result[2]]) {\n+ expect(skipped.isNewRecord).to.equal(true);\n+ expect(skipped.id).to.equal(null);\n+ expect(skipped.secretValue).to.equal('dup');\n+ // nothing was stored for it, so it carries no generated timestamps either\n+ expect(skipped.createdAt).to.equal(undefined);\n+ expect(skipped.updatedAt).to.equal(undefined);\n+ }\n+ });\n+\n+ it('does not report any record as persisted when every row is skipped', async () => {\n+ const { User } = vars;\n+ await User.bulkCreate([{ uniqueName: 'Peter' }, { uniqueName: 'Paul' }]);\n+\n+ const result = await User.bulkCreate([{ uniqueName: 'Peter' }, { uniqueName: 'Paul' }], {\n+ ignoreDuplicates: true,\n+ });\n+\n+ expect(result.map(user => user.uniqueName)).to.deep.equal(['Peter', 'Paul']);\n+ for (const user of result) {\n+ expect(user.isNewRecord).to.equal(true);\n+ expect(user.id).to.equal(null);\n+ }\n+\n+ expect(await User.count()).to.equal(2);\n+ });\n+\n+ it('does not store the children of a skipped record under another record', async () => {\n+ const { User, Task } = vars;\n+ await User.bulkCreate([{ uniqueName: 'Peter' }]);\n+\n+ const records = [\n+ { uniqueName: 'Peter', secretValue: null, tasks: [{ title: 'peter-task' }] },\n+ { uniqueName: 'Michael', secretValue: null, tasks: [{ title: 'michael-task' }] },\n+ ];\n+ const result = await User.bulkCreate(records, {\n+ ignoreDuplicates: true,\n+ include: [{ model: Task, as: 'tasks' }],\n+ });\n+\n+ const michael = await User.findOne({ where: { uniqueName: 'Michael' }, rejectOnEmpty: true });\n+ expect(result[1].id).to.equal(michael.id);\n+\n+ const tasks = await Task.findAll({ order: ['id'], raw: true });\n+ expect(tasks).to.have.length(1);\n+ expect(tasks[0].title).to.equal('michael-task');\n+ expect(tasks[0].userId).to.equal(michael.id);\n+\n+ expect(result[0].isNewRecord).to.equal(true);\n+ expect(result[0].tasks![0].isNewRecord).to.equal(true);\n+ });\n+\n+ it('matches on a composite unique key', async () => {\n+ const { Seat } = vars;\n+ await Seat.bulkCreate([{ room: 'A', number: 1, label: 'taken' }]);\n+\n+ const result = await Seat.bulkCreate(\n+ [\n+ { room: 'A', number: 1, label: 'dup' },\n+ { room: 'A', number: 2, label: 'new' },\n+ { room: 'B', number: 1, label: 'new' },\n+ ],\n+ { ignoreDuplicates: true },\n+ );\n+\n+ const rows = await Seat.findAll({ order: ['id'], raw: true });\n+ expect(rows).to.have.length(3);\n+ expect(result[0].isNewRecord).to.equal(true);\n+ expect(result[0].label).to.equal('dup');\n+ expect(result[1].id).to.equal(rows[1].id);\n+ expect(result[1].room + result[1].number).to.equal('A2');\n+ expect(result[2].id).to.equal(rows[2].id);\n+ expect(result[2].room + result[2].number).to.equal('B1');\n+ });\n+\n+ it('matches on a caller-supplied primary key', async () => {\n+ const { Code } = vars;\n+ await Code.bulkCreate([{ code: 'x', label: 'taken' }]);\n+\n+ const result = await Code.bulkCreate(\n+ [\n+ { code: 'x', label: 'dup' },\n+ { code: 'y', label: 'new' },\n+ ],\n+ { ignoreDuplicates: true },\n+ );\n+\n+ expect(result[0].isNewRecord).to.equal(true);\n+ expect(result[0].label).to.equal('dup');\n+ expect(result[1].isNewRecord).to.equal(false);\n+ expect(result[1].label).to.equal('new');\n+ expect((await Code.findByPk('x', { rejectOnEmpty: true })).label).to.equal('taken');\n+ });\n+\n+ it('keeps the rows aligned when the returning list omits the key columns', async () => {\n+ const { User } = vars;\n+ await User.bulkCreate([{ uniqueName: 'Peter', secretValue: '42' }]);\n+\n+ const result = await User.bulkCreate(\n+ [\n+ { uniqueName: 'Peter', secretValue: 'dup' },\n+ { uniqueName: 'Michael', secretValue: '26' },\n+ ],\n+ { ignoreDuplicates: true, returning: ['id'] },\n+ );\n+\n+ const michael = await User.findOne({ where: { uniqueName: 'Michael' }, rejectOnEmpty: true });\n+ expect(result[0].isNewRecord).to.equal(true);\n+ expect(result[0].id).to.equal(null);\n+ expect(result[1].id).to.equal(michael.id);\n+ expect(result[1].isNewRecord).to.equal(false);\n+ });\n+});\n" }, "isError": false, "subscores": [ { "name": "aligned_inserted", "weight": 0.1875, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION aligned_inserted: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh aligned_inserted", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "skipped_honest", "weight": 0.125, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION skipped_honest: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh skipped_honest", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "expression_columns", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION expression_columns: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh expression_columns", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "skipped_timestamps", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION skipped_timestamps: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh skipped_timestamps", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "returning_restricted", "weight": 0.125, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION returning_restricted: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh returning_restricted", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "date_key", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION date_key: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh date_key", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "children_attachment", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION children_attachment: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh children_attachment", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "key_variants", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION key_variants: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh key_variants", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "untouched_paths", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION untouched_paths: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh untouched_paths", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "no_regression", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": "CRITERION no_regression: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh no_regression", "cwd": "/workspace/repo", "timeout_seconds": 1800 } } }, { "name": "test_quality", "weight": 0.0625, "value": 1.0, "children": null, "info": { "exit_code": 0, "stdout": " [grader] agent test files: integration/model/bulk-create/ignore-duplicates.test.ts\nCRITERION test_quality: PASS\n", "stderr": "", "_parameters": { "command": "bash /hud/grader/run_grading.sh test_quality", "cwd": "/workspace/repo", "timeout_seconds": 900 } } }, { "name": "maintainer_review", "weight": 0.0625, "value": 1.0, "children": [ { "name": "The diff changes the behaviour of the bulk-create path in packages/core/src/model.js (a diff that adds only comments, whitespace or formatting does not) and stays on-ticket: changes are confined to that path and closely related code, plus its tests. No unrelated drive-by edits, and no edits to pre-existing test files.", "weight": 1.0, "value": 1.0, "children": null, "info": { "reason": "The diff changes bulkCreate behaviour in model.js. It matches returned rows to records by key, tracks skipped instances, skips children of skipped parents, and widens the returning list. The two new static helpers serve only this path. The only test change is a new test file, and no pre-existing test files are edited. I found no unrelated drive-by edits." } }, { "name": "Judge only the lines the diff adds to packages/core/src/model.js; ignore test files and every other file. The ticket requires the behaviour to hold \"whatever the model definition\". Check this mechanically: list every quoted string literal (single, double or backtick quotes) in those added lines. Answer No only if one of those literals is exactly equal to one of these names used by the ticket's or the tests' models: 'id', 'uniqueName', 'secretValue', 'createdAt', 'updatedAt', 'deletedAt', 'room', 'number', 'code', 'label', 'title', 'userId', 'users', 'User', 'Task', 'Seat', 'Code'. Every other literal counts as Yes, for example type names in typeof checks such as 'string' or 'object', encodings such as 'hex', separators such as '\\0' or ':', option names such as 'ignoreDuplicates' or 'returning', dialect names, error messages, and keys the code makes up for its own bookkeeping. Reading names through variables, loops, attribute.field, primaryKeys, rawAttributes, getIndexes() or other model metadata is not a quoted literal and counts as Yes. If no added line contains one of the listed names as a whole quoted literal, answer Yes. Do not mark this No for weaknesses in the matching logic itself; other checks grade behaviour.", "weight": 1.0, "value": 1.0, "children": null, "info": { "reason": "The quoted literals added to model.js are 'string', 'hex', '\\0', the `${k}:${...}` template and two error-message templates. None of them exactly equals a listed name such as 'id', 'uniqueName' or 'User'. Key and column names are read from model metadata (primaryKeys, attribute.field, getIndexes(), columns) rather than hardcoded." } }, { "name": "At least one test file added by the diff calls bulkCreate with ignoreDuplicates: true on a batch in which at least one record conflicts with a row already in the table, and asserts on the instances returned by that same call: for an inserted record, isNewRecord is false and its primary key equals the key of its row in the table; for a skipped record, isNewRecord is true. Assertions made only on the table contents (count, findAll) do not meet this criterion.", "weight": 1.0, "value": 1.0, "children": null, "info": { "reason": "The first integration test in ignore-duplicates.test.ts calls User.bulkCreate with ignoreDuplicates: true on a batch where Peter and Paul already exist in the table. It asserts on the instances returned by that same call. For the inserted records (Michael, Anna), isNewRecord is false and id equals the id of the matching row read back with findAll. For the skipped records (Peter, Paul), isNewRecord is true. These are assertions on the returned instances, not only on table contents." } } ], "info": { "model": "anthropic/claude-sonnet-5.5", "_parameters": { "answer": "(answer elided; 18232 chars)", "criteria": [ "The diff changes the behaviour of the bulk-create path in packages/core/src/model.js (a diff that adds only comments, whitespace or formatting does not) and stays on-ticket: changes are confined to that path and closely related code, plus its tests. No unrelated drive-by edits, and no edits to pre-existing test files.", "Judge only the lines the diff adds to packages/core/src/model.js; ignore test files and every other file. The ticket requires the behaviour to hold \"whatever the model definition\". Check this mechanically: list every quoted string literal (single, double or backtick quotes) in those added lines. Answer No only if one of those literals is exactly equal to one of these names used by the ticket's or the tests' models: 'id', 'uniqueName', 'secretValue', 'createdAt', 'updatedAt', 'deletedAt', 'room', 'number', 'code', 'label', 'title', 'userId', 'users', 'User', 'Task', 'Seat', 'Code'. Every other literal counts as Yes, for example type names in typeof checks such as 'string' or 'object', encodings such as 'hex', separators such as '\\0' or ':', option names such as 'ignoreDuplicates' or 'returning', dialect names, error messages, and keys the code makes up for its own bookkeeping. Reading names through variables, loops, attribute.field, primaryKeys, rawAttributes, getIndexes() or other model metadata is not a quoted literal and counts as Yes. If no added line contains one of the listed names as a whole quoted literal, answer Yes. Do not mark this No for weaknesses in the matching logic itself; other checks grade behaviour.", "At least one test file added by the diff calls bulkCreate with ignoreDuplicates: true on a batch in which at least one record conflicts with a row already in the table, and asserts on the instances returned by that same call: for an inserted record, isNewRecord is false and its primary key equals the key of its row in the table; for a skipped record, isNewRecord is true. Assertions made only on the table contents (count, findAll) do not meet this criterion." ], "question": "(question elided; 441 chars)", "model": "anthropic/claude-sonnet-5.5" } } } ] }