Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Conversation

@soedirgo
Copy link
Member

@soedirgo soedirgo commented May 8, 2021

What kind of change does this PR introduce?

Bug fix.

What is the current behavior?

Bulk insert doesn't have columns param.

What is the new behavior?

Adds the param. Fixes #175.

Copy link
Member

@steve-chavez steve-chavez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@steve-chavez
Copy link
Member

@soedirgo Q: How can I test this against a local postgrest? These steps don't work for me with node.

Is there an easy way I can try the library on the terminal?

@soedirgo
Copy link
Member Author

soedirgo commented May 9, 2021

👍

Is there an easy way I can try the library on the terminal?

This should do it (after npm run build):

const { PostgrestClient } = require('.')

const REST_URL = 'http://localhost:3000'
const postgrest = new PostgrestClient(REST_URL)

postgrest
    .from('users')
    .select()
    .then(console.log)

@soedirgo soedirgo merged commit c865235 into master May 9, 2021
@soedirgo soedirgo deleted the fix/columns-param branch May 9, 2021 01:16
@github-actions
Copy link

github-actions bot commented May 9, 2021

🎉 This PR is included in version 0.28.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

@steve-chavez
Copy link
Member

steve-chavez commented May 9, 2021

@soedirgo Awesome. Thanks!

I've just confirmed that the PR is working.

Did this:

postgrest
    .from('projects')
    .insert([
      {id: 123, name: "project-123", nonexistent: "val"},
      {id: 345, name: "project-345"}
    ])
    .then(console.log)

And the error is much clearer now.

{
  error: {
    hint: null,
    details: null,
    code: '42703',
    message: 'column "nonexistent" of relation "projects" does not exist'
  }
  //...
}

Before the error message was stark:

{
error: { message: 'All object keys must match' }
//...
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use columns query parameter for insert

3 participants