@@ -99,11 +99,9 @@ func (rs *ResultSet) Union(other *ResultSet) *ResultSet {
99
99
}
100
100
101
101
for iter := other .List (); iter != nil ; iter = iter .Next () {
102
- isImplicit := iter .IsImplicit
103
- if resultSet .Has (iter .ObjectType , iter .ObjectId , iter .Relation ) {
104
- isImplicit = isImplicit && resultSet .Get (iter .ObjectType , iter .ObjectId , iter .Relation ).IsImplicit
102
+ if ! resultSet .Has (iter .ObjectType , iter .ObjectId , iter .Relation ) || ! iter .IsImplicit {
103
+ resultSet .Add (iter .ObjectType , iter .ObjectId , iter .Relation , iter .Warrant , iter .IsImplicit )
105
104
}
106
- resultSet .Add (iter .ObjectType , iter .ObjectId , iter .Relation , iter .Warrant , isImplicit )
107
105
}
108
106
109
107
return resultSet
@@ -112,10 +110,13 @@ func (rs *ResultSet) Union(other *ResultSet) *ResultSet {
112
110
func (rs * ResultSet ) Intersect (other * ResultSet ) * ResultSet {
113
111
resultSet := NewResultSet ()
114
112
for iter := rs .List (); iter != nil ; iter = iter .Next () {
115
- isImplicit := iter .IsImplicit
116
113
if other .Has (iter .ObjectType , iter .ObjectId , iter .Relation ) {
117
- isImplicit = isImplicit || other .Get (iter .ObjectType , iter .ObjectId , iter .Relation ).IsImplicit
118
- resultSet .Add (iter .ObjectType , iter .ObjectId , iter .Relation , iter .Warrant , isImplicit )
114
+ otherRes := other .Get (iter .ObjectType , iter .ObjectId , iter .Relation )
115
+ if ! otherRes .IsImplicit {
116
+ resultSet .Add (otherRes .ObjectType , otherRes .ObjectId , otherRes .Relation , otherRes .Warrant , otherRes .IsImplicit )
117
+ } else {
118
+ resultSet .Add (iter .ObjectType , iter .ObjectId , iter .Relation , iter .Warrant , iter .IsImplicit )
119
+ }
119
120
}
120
121
}
121
122
@@ -125,7 +126,11 @@ func (rs *ResultSet) Intersect(other *ResultSet) *ResultSet {
125
126
func (rs * ResultSet ) String () string {
126
127
var strs []string
127
128
for iter := rs .List (); iter != nil ; iter = iter .Next () {
128
- strs = append (strs , fmt .Sprintf ("%s => %s" , key (iter .ObjectType , iter .ObjectId , iter .Relation ), iter .Warrant .String ()))
129
+ if iter .IsImplicit {
130
+ strs = append (strs , fmt .Sprintf ("%s => %s [implicit]" , key (iter .ObjectType , iter .ObjectId , iter .Relation ), iter .Warrant .String ()))
131
+ } else {
132
+ strs = append (strs , fmt .Sprintf ("%s => %s" , key (iter .ObjectType , iter .ObjectId , iter .Relation ), iter .Warrant .String ()))
133
+ }
129
134
}
130
135
131
136
return strings .Join (strs , ", " )
0 commit comments