CUAHSI / HydroServer

BSD 3-Clause "New" or "Revised" License
8 stars 4 forks source link

ODM for MySQL - duplicate records in datavalues table #125

Open xhqiao89 opened 7 years ago

xhqiao89 commented 7 years ago

jirikadlec2[CodePlex]
Originally reported by Silvano Pecora and confirmed by Jiri Kadlec: The MySql version of ODM is not correct in handling the index in the table datavalues, which is totally different in comparison with SqlServer, even if MySql version is correct and sql compliant. The index is defined with nullable fields and sqlserver handles them in such a way that null=null; but mysql has a correct nullltgtnull because they are undefined values. The result is that in mysql we can have duplicated, triplicated, …, values in the database.

A patch has been suggested: The workaround is the creation of temporary fields, corresponding to the fields of the index, which are handled by two triggers (insert and update) for inserting or updating -1 for null, otherways the same value. The index is composed by these temporary fields.

The sql file with the patch contributed by Silvano is attached.