aniketsupertramp / freeze-messenger

Automatically exported from code.google.com/p/freeze-messenger
Other
0 stars 0 forks source link

Remove On-Duplicate Key Requirement #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently, FreezeMessenger makes liberal use of MySQL's 
INSERT-ON-DUPLICATE-KEY-UPDATE (aka upsert) functionality. This functionality 
is not present in all MySQL databases (e.g. PostGreSQL) and would be very hard 
to implement in non-SQL databases.

Instead, these type of queries should get their own function in the database 
called upsert, accepting the params ($conditionArray, $dataArray), which would 
do something like this:

if (!select($conditionArray)) {
  insert($dataArray);
}
else update($conditionArray, $dataArray)

In databases with existing upsert functionality, this could instead be 
performed as

INSERT $dataArray ON DUPLICATE KEY UPDATE unMerge($conditionArray, $dataArray)

This will require converting all existing insert() calls.

Original issue reported on code.google.com by JosephTP...@gmail.com on 31 Mar 2014 at 10:33

GoogleCodeExporter commented 9 years ago
Note: While locking will not be a priority, it should still in some cases be 
considered.

Original comment by JosephTP...@gmail.com on 31 Mar 2014 at 10:36