-
Notifications
You must be signed in to change notification settings - Fork 6
The "on duplicate" does not work in hsql DB, changed to "on conflict" #21
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
base: main
Are you sure you want to change the base?
Conversation
|
Thanks! Can you confirm if, after this update, the code will be compatible with all other database systems that Openfire supports? |
|
Not yet. I'll check all the databases and then write either a SQL function based logic (Try catch based), or change the query based on the DB used. This is just the basic fix that I had to do while implementing a chat box in my organisation where I used postgre as well as HSQLDB and the implementation failed directly in both, resulting a direct error in the openfire logs itself. |
|
Some other plugins, like the Monitoring plugin, have code that use different SQL based on the type of database that is being used. Maybe you can get inspiration from there. Alternatively, maybe the code can be rewritten so that it is compatible with all database servers (e.g. do a DELETE first, then an INSERT). |
|
Yes I've actually implemented the monitoring plugin and it works on the logic that you've said and we could probably use that as well (but that'd be a hail mary because it requires major codebase changes, and would probably require more changes in the future if another DB is added.) I'll first check if the conflict logic works in all the DBs. Also, on a separate note, I haven't actually been able to send a Firebase notification using the plugin (even after the logs say that it's delivered : PushInterceptor.java:L275). |
I functionally know very little about what this plugin is supposed to do. I don't think it has been updated in a while, so if there are new restrictions, then it may very well be the case that those have not yet been implemented here. Hopefully the original authors |
According to my RnD, the previously implemented "ON DUPLICATE" works only with MySQL DB (this was probably the DB used when developing the plugin). The updated "ON CONFLICT" query works in all major DBs, except for MySQL. However, the default DB for OpenFire (HSQL DB) supports neither of them. We can either change the query according to the DB(as suggested), or provide this implementation. Try/Catch or a case based SQL approach does not wok in DML of any SQL, hence a count query would be more appropriate. Also, I do not know kotlin and would very much appreciate any input in optimizing the code if possible. Note: With this approach, we can effectively remove the unique constraint on the table as it would merely be a precaution with time overhead.
|
According to my RnD, the previously implemented "ON DUPLICATE" works However, the default DB for OpenFire (HSQL DB) supports neither of them. We can either change the query according to the DB(as suggested), or Try/Catch or a case based SQL approach does not wok in DML of any SQL, Also, I do not know kotlin and would very much appreciate any input in Note: With this approach, we can effectively remove the unique constraint on the table as it would merely be a precaution with time overhead. |
A working example for HSQL DB compiler