Giter Site home page Giter Site logo

Comments (7)

punund avatar punund commented on May 25, 2024

Affects me too.

from loopback-connector-postgresql.

BerkeleyTrue avatar BerkeleyTrue commented on May 25, 2024

+1 This connector needs some love!

from loopback-connector-postgresql.

BerkeleyTrue avatar BerkeleyTrue commented on May 25, 2024

See this PR for fix! #40

from loopback-connector-postgresql.

raymondfeng avatar raymondfeng commented on May 25, 2024

@BerkeleyTrue Thank you for the patch. I think the issue is even more involved. The upsert is mapped to a SQL statement as follows:

WITH update_outcome AS 
(UPDATE "public"."postwithboolean" 
SET "title"=$1,"content"=$2,"approved"=$3 
WHERE  "id"=$4 RETURNING "id"), 
insert_outcome AS 
(INSERT INTO "public"."postwithboolean" ("title","content","approved","id") 
SELECT $1,$2,$3,$4  WHERE NOT EXISTS 
(SELECT * FROM update_outcome) 
RETURNING "id") 
SELECT * FROM update_outcome UNION ALL SELECT * FROM insert_outcome

The usage of writable CTE requires Postgresql 9.1 or later. See http://www.postgresql.org/docs/9.2/static/queries-with.html.

One fix is just remove the native implementation from the postgresql connector so that https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/dao.js#L264 will kick in. It basically tries to find by id first and create if not found.

from loopback-connector-postgresql.

BerkeleyTrue avatar BerkeleyTrue commented on May 25, 2024

Thanks Raymond, I wasn't aware of DAO method. I have update my PR accordingly.

from loopback-connector-postgresql.

raymondfeng avatar raymondfeng commented on May 25, 2024

It should be fixed by [email protected] now.

from loopback-connector-postgresql.

BerkeleyTrue avatar BerkeleyTrue commented on May 25, 2024

This issue is resolved and should be closed.

from loopback-connector-postgresql.

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.