‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, May 19, 2019 4:44 PM, John Fawcett via dovecot <dovecot@dovecot.org> 
wrote:

> I don't have PostgresSql, would you be able to verify if this syntax would 
> work: INSERT INTO last_logins (last_login,username,domain) VALUES 
> (1558273000,'u...@domain.tld','domain.tld') ON CONFLICT(username) UPDATE SET 
> last_login=1558273000,domain='u...@domain.tld' It's important to check that 
> this updates only the single row for that user and it puts the right data in 
> that row. If it doesn't work can you give the correct syntax?

So you nearly yes ;-) The only parameter missing was "DO" keyword before the 
"UPDATE". So the correct query would be:

INSERT INTO last_logins (last_login,username,domain) VALUES 
(1558273000,'u...@domain.tld','domain.tld') ON CONFLICT (username) DO UPDATE 
SET last_login=1558273000,domain='domain.tld';

I also adapted the domain='domain.tld' at the end of the query, you had 
domain='u...@domain.tld' but this is just a "content" detail which does not 
matter.

Hope that helps. Let me know if I can do any further testing.

Reply via email to