Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Support for returning uuid from batch INSERT #97

Open
marracuene opened this issue Jun 16, 2021 · 0 comments
Open

Feature Request: Support for returning uuid from batch INSERT #97

marracuene opened this issue Jun 16, 2021 · 0 comments

Comments

@marracuene
Copy link

https://github.com/jeremydaly/data-api-client#retrieving-insert-ids says:

The Data API returns a generatedFields array that contains the value of auto-incrementing primary keys. If this value is returned, > the Data API Client will parse this and return it as the insertId. This also works for batch queries as well.

What about for generated UUID primary keys?

For example with a table like this:

CREATE TABLE test
(
	id uuid primary key default uuid_generate_v4(),
	country text not null,
	name text	
);

and an insert query like this:

`INSERT INTO test(country, name) VALUES(:country, :name)

Would it be possible access the generated uuid in the data-api-client result structure?

NOTE: using data-api-client with Postgres, one can append RETURNING id to the above INSERT statement, and then access the returned id field on the results.records structure, just as though it were a column returned by a SELECT statement. We are using this in production with single inserts and it works perfectly. However switching to batch inserts, the rows are still inserted but nothing is returned.

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

No branches or pull requests

1 participant