Code Monkey home page Code Monkey logo

Comments (11)

porsager avatar porsager commented on July 18, 2024 1

Hi. Great error report! Thank you!

I think your expectations are correct, so that's quite the bug you've found here. I'll dig into it.

from postgres.

porsager avatar porsager commented on July 18, 2024 1

Ok, I found the issue. It was accidentally trying to use the routineRetry logic for simple queries (should only be used for prepared statements), which makes no sense, and messes with the protocol expectations for simple queries.

You can try it out by installing latest master using npm i porsager/postgres

Related to your issue 2, you have a stray "async" for your function. The function should look like this:

import postgres from 'postgres'

const sql = postgres({ max: 1 });

await sql.begin(sql => [
  sql`
    CREATE TABLE user_permissions (
      permissions TEXT[] NOT NULL
    )
  `,
  sql`
    INSERT INTO user_permissions (permissions)
    VALUES (('read', 'write', 'delete'))
  `,
]);

await sql.end();

from postgres.

aslushnikov avatar aslushnikov commented on July 18, 2024

This is awesome, thank you for the quick fix!

from postgres.

aslushnikov avatar aslushnikov commented on July 18, 2024

You can try it out by installing latest master using npm i porsager/postgres

@porsager I just tried, but the issue still reproduces for me on tip-of-tree. I tried cloning & building the repository, but no luck!

from postgres.

porsager avatar porsager commented on July 18, 2024

Didn't transpile for cjs etc, so if you're not using the esm version that might be it. Just a sec 😊

from postgres.

porsager avatar porsager commented on July 18, 2024

Try again now 😉

from postgres.

porsager avatar porsager commented on July 18, 2024

If there's still an error, do post it 👍

from postgres.

aslushnikov avatar aslushnikov commented on July 18, 2024

Still no luck; here's the exact thing that I try: https://github.com/aslushnikov/postgres-js-issue-repro

To validate the repro, there's a commented-out node-postgres code snippet that does throw an error:

https://github.com/aslushnikov/postgres-js-issue-repro/blob/efac21d154e790334a31c93e36cd4bb9241441bf/test.mjs#L16-L21

from postgres.

aslushnikov avatar aslushnikov commented on July 18, 2024

To make sure this is not something specific to my machine, here are Github Actions running this test: https://github.com/aslushnikov/postgres-js-issue-repro/actions/runs/8364618788/job/22900381583

from postgres.

porsager avatar porsager commented on July 18, 2024

There we go :-) Single character mistake - sorry

from postgres.

aslushnikov avatar aslushnikov commented on July 18, 2024

@porsager awesome, it works now!

I had to build it manually since installation from GH doesn't work. That's not an issue for me though – i'll happily wait for the next release.

Thank you!

from postgres.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.