Re: Upsert error "column reference is ambiguous" - Mailing list pgsql-general

From Laurenz Albe
Subject Re: Upsert error "column reference is ambiguous"
Date
Msg-id 10ff0fbe7f4d711300951431ad28254aa5bf2dc4.camel@cybertec.at
Whole thread Raw
In response to Re: Upsert error "column reference is ambiguous"  (Tim Starling <tstarling@wikimedia.org>)
Responses Re: Upsert error "column reference is ambiguous"
List pgsql-general
On Tue, 2025-04-29 at 08:36 +1000, Tim Starling wrote:
> My code would be like
>
> function upsert( $table, $names, $values, $key, $set ) {
>      if ( $this->type === 'mysql' ) {
>          $conflict = 'ON DUPLICATE KEY UPDATE';
>      } else {
>          $conflict = "ON CONFLICT ($key) DO UPDATE SET";
>      }
>      return $this->query( "INSERT INTO $table ($names) " .
>          "VALUES ($values) $conflict $set" );
> }
>
> The parameters are a little bit more structured than that, but that
> gives you the idea.

Another litle "if" to cater for PostgreSQL's "EXCLUDED." would be
such a big problem?

Yours,
Laurenz Albe



pgsql-general by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: Upsert error "column reference is ambiguous"
Next
From: Vydehi Ganti
Date:
Subject: Re: Clarification on RLS policy