Dict issue with PostgreSQL for last_login plugin (duplicate key)

mabi mabi at protonmail.ch
Sun May 19 18:08:12 EEST 2019


‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐
On Sunday, May 19, 2019 4:44 PM, John Fawcett via dovecot <dovecot at 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,'user at domain.tld','domain.tld') ON CONFLICT(username) UPDATE SET last_login=1558273000,domain='user at 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,'user at 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='user at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://dovecot.org/pipermail/dovecot/attachments/20190519/78faf344/attachment.html>


More information about the dovecot mailing list