Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request ON DUPLICATE KEY #226

Open
Flowman opened this issue Mar 2, 2021 · 18 comments
Open

Feature Request ON DUPLICATE KEY #226

Flowman opened this issue Mar 2, 2021 · 18 comments

Comments

@Flowman
Copy link

Flowman commented Mar 2, 2021

Feature request to extend the database driver ON DUPLICATE KEY functionality

Documentation for each typ of database:

joomla/joomla-cms#32559

@richard67
Copy link
Contributor

MySQL supports statements like INSERT ... ON DUPLICATE KEY UPDATE ... since at leat version 5.6: https://dev.mysql.com/doc/refman/5.6/en/insert-on-duplicate.html

MariaDB seems to support the same since at least some 7 years: https://mariadb.com/kb/en/insert-on-duplicate-key-update/

PostgreSQL supports statements like INSERT ... ON CONFLICT ... DO UPDATE SET ... since at leat version 9.6: https://www.postgresql.org/docs/9.6/sql-insert.html

So it should be possible to implement support for that in the 2.0-dev branch here for version 4 of the CMS.

@nibra
Copy link
Contributor

nibra commented Mar 2, 2021

We need to define when to use the UPDATE fallback. I'd suggest to use REPLACE (which MySQL supports since ages),
See https://dev.mysql.com/doc/refman/8.0/en/replace.html
The behaviour would be different, though, as the native REPLACE deletes records that are in the way for INSERT, while our implementation would do an UPDATE in case on conflict.
Any objections?

@richard67
Copy link
Contributor

@nibra I don't think there is something like MySQL's REPLACE for PostgreSQL, since it's absolutely not SQL standard.

@alikon
Copy link
Contributor

alikon commented Mar 2, 2021

even if i don't like upsert
I think upsert should be a nice to have feature

but should avoid SQL dialects

@richard67
Copy link
Contributor

@nibra Or did I get you wrong, thinking you suggest to use INSERT while you just were suggesting it as name for the new function? Well, I'd prefer something similar to what @Flowman has suggested in the discussion in the CMS repo: joomla/joomla-cms#32559 (reply in thread)

I'd maybe use something like insertOrUpdateObject and query->onDuplicateKeyUpdate regarding the naming.

@alikon
Copy link
Contributor

alikon commented Mar 2, 2021

maybe it's my MongoDB old memories 😄

@alikon
Copy link
Contributor

alikon commented Mar 2, 2021

@nibra
Copy link
Contributor

nibra commented Mar 3, 2021

I'd maybe use something like insertOrUpdateObject and query->onDuplicateKeyUpdate regarding the naming.

I like the names as they are self-explanatory.
The problem I see is that we cannot safely provide this feature for other databases than MySQL (MariaDB) and PostgreSQL.

@richard67
Copy link
Contributor

The problem I see is that we cannot safely provide this feature for other databases than MySQL (MariaDB) and PostgreSQL.

Do we have to support others in the 2.0-dev branch?

@nibra
Copy link
Contributor

nibra commented Mar 3, 2021

Yes, MS SQL Server. To drop it, we need an official decision by the Production Department.

@richard67
Copy link
Contributor

@nibra In Joomla 4 it has been dropped for sure. I thought that's the case here in the 2.0-dev branch, too.

@Llewellynvdm
Copy link

Llewellynvdm commented Mar 3, 2021

@richard67 am I understanding you correctly, that support for MS SQL is dropped in Joomla 4? When did that happen... forgive me for asking but I missed that... not that I mind 👍

@alikon
Copy link
Contributor

alikon commented Mar 3, 2021

on J4 for sure https://downloads.joomla.org/technical-requirements
on https:/joomla-framework/database debatable

@richard67
Copy link
Contributor

@Llewellynvdm Yes, see https://docs.joomla.org/Potential_backward_compatibility_issues_in_Joomla_4 , the top section "Updated System Requirements":

SQL Server support has been dropped.

@Llewellynvdm
Copy link

You got me... guilty as charged I did not read. Thanks!

@Llewellynvdm
Copy link

But I was actually looking for the conversation minutes in PTL that lead to that...

@richard67
Copy link
Contributor

But I was actually looking for the conversation minutes in PTL that lead to that...

@Llewellynvdm Then you have to look some 4 or 5 years back ;-)

@Llewellynvdm
Copy link

Just shaking my head.... and the then we move on... lol

Thanks @richard67 that was before my time, when the J4 journey started I suppose....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants