Skip to content

Add batch insert support via array parameter#151

Merged
devbro1 merged 9 commits intomasterfrom
copilot/modify-insert-command-array
Jan 31, 2026
Merged

Add batch insert support via array parameter#151
devbro1 merged 9 commits intomasterfrom
copilot/modify-insert-command-array

Conversation

Copy link
Contributor

Copilot AI commented Jan 29, 2026

Description

insert() and insertGetId() now accept arrays to generate single-statement batch inserts instead of requiring multiple query executions.

Before:

await query.table('users').insert({ name: 'John', email: 'john@ex.com' });
await query.table('users').insert({ name: 'Jane', email: 'jane@ex.com' });

After:

await query.table('users').insert([
  { name: 'John', email: 'john@ex.com' },
  { name: 'Jane', email: 'jane@ex.com' }
]);
// SQL: INSERT INTO users (name, email) VALUES (?, ?), (?, ?)

Changes:

  • Updated Query.insert() and Query.insertGetId() signatures to accept Record<string, Parameter> | Record<string, Parameter>[]
  • Modified QueryGrammar.compileInsert() to generate multi-value SQL when array provided
  • Updated MySQL, PostgreSQL, and SQLite grammar implementations
  • Added validation for empty arrays/objects
  • Column schema derived from first array element; missing keys in subsequent objects insert as undefined

Limitations:

  • SQLite: 999 parameter limit, PostgreSQL: 65,535 parameter limit
  • MySQL insertGetId returns only first ID on batch inserts (driver limitation)

Checklist

  • lint/prettier
  • updated docs with new feature/details
  • added tests that cover changes
  • Add jsdocs for any added function/class

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • undefined
    • Triggering command: /usr/lib/postgresql/16/bin/psql /usr/lib/postgresql/16/bin/psql --host undefined --user undefined --port 5432 postgres -c CREATE DATABASE test_db_3l2d4 (dns block)
    • Triggering command: /usr/lib/postgresql/16/bin/psql /usr/lib/postgresql/16/bin/psql --host undefined --user undefined --port 5432 postgres -c CREATE DATABASE test_db_c59syd https://github.cvitest run batch_insert.spec.ts git conf�� 20.0/include/node --local 20.0/src credential.helpesh 20.0/deps/openss-c (dns block)
    • Triggering command: /usr/lib/postgresql/16/bin/psql /usr/lib/postgresql/16/bin/psql --host undefined --user undefined --port 5432 postgres -c CREATE DATABASE test_db_oln63p (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>neko-sql insert, allow for inserting an array</issue_title>
<issue_description>modify insert command to accept array.
if array is given then sql statement should be a single statement to insert multiple entries.</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 29, 2026 23:21
Co-authored-by: devbro1 <29712935+devbro1@users.noreply.github.com>
Co-authored-by: devbro1 <29712935+devbro1@users.noreply.github.com>
Copilot AI changed the title [WIP] Update neko-sql insert to allow for inserting an array Add batch insert support via array parameter Jan 29, 2026
Copilot AI requested a review from devbro1 January 29, 2026 23:28
devbro1 and others added 6 commits January 31, 2026 03:48
branch name: copilot/modify-insert-command-array
branch name: copilot/modify-insert-command-array
branch name: copilot/modify-insert-command-array
@devbro1 devbro1 marked this pull request as ready for review January 31, 2026 04:12
@devbro1 devbro1 merged commit 42eb9e8 into master Jan 31, 2026
@devbro1 devbro1 deleted the copilot/modify-insert-command-array branch January 31, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

neko-sql insert, allow for inserting an array

2 participants