Skip to content

Bulk Inserts #2254

Open
Open
@philon123

Description

@philon123

What do you want to change?

I would like to use queries like

INSERT INTO books(id, name) VALUES
(NULL, 'Notebook'),
(NULL, 'MacBook'),
(NULL, 'BookBook')
..;

We have support for COPY here, but it's not as flexible or as easy to use as the above syntax. Also, the above syntax allows for ON CONFLICT(id) UPDATE name = EXCLUDED.name, which is great for bulk updates / upserts.

The generated Go code should take a list of Param objects as input. I'm not quite sure how the SQL template should look, but maybe something like

-- name: BulkInsertBooks :bulk
INSERT INTO books(id, name) VALUES @bulkBookRows;

What database engines need to be changed?

PostgreSQL

What programming language backends need to be changed?

Go

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions