#336: bhdashboard.model.ModelBase insert method fails if no unique fields
specified
---------------------------+------------------------------
Reporter: franco | Owner: nobody
Type: defect | Status: new
Priority: critical | Milestone:
Component: multiproduct | Version: 0.3.0
Resolution: | Keywords: model sql insert
---------------------------+------------------------------
Changes (by olemis):
* keywords: => model sql insert
Comment:
Replying to [comment:2 gjm]:
>
[...]
> The diff below would be similar to your suggestion.
>
> {{{
> #!diff
> Index: bloodhound_dashboard/bhdashboard/model.py
> ===================================================================
> --- bloodhound_dashboard/bhdashboard/model.py (revision 1429887)
> +++ bloodhound_dashboard/bhdashboard/model.py (working copy)
> @@ -145,7 +145,7 @@
> for k in
self._meta['key_fields']]))):
> sdata = {'keys':','.join(["%s='%s'" % (k, self._data[k])
> for k in
self._meta['key_fields']])}
> - elif len(self.select(self._env, where =
> + elif self._meta['unique_fields'] and len(self.select(self._env,
where =
> dict([(k,self._data[k])
> }}}
>
> This appears to fix the testcase you suggest but I have not checked
through the full consequences of the change yet.
IMO that's not enough due to the fact that `WHERE` clause will check for
the combination of unique fields . IOW for UNIQUE checks the logic op
should be `OR` instead of `AND` .
CMIIW
--
Ticket URL: <https://issues.apache.org/bloodhound/ticket/336#comment:3>
Apache Bloodhound <https://issues.apache.org/bloodhound/>
The Apache Bloodhound (incubating) issue tracker