Skip to content

Commit 58234a7

Browse files
author
Marco Veglio
committed
Fixed names on rename operation
1 parent e9e8560 commit 58234a7

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Code/Epic.Query/Relational/Operations/Rename.cs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ public sealed class Rename: Relation, IEquatable<Rename>
4444
/// The new name given to the relation.
4545
/// </param>
4646
public Rename (Relation relation, string newRelationName):
47-
base(RelationType.BaseRelation, getDefaultName (relation, newRelationName))
47+
base(RelationType.BaseRelation, getDefaultName (relation))
4848
{
49+
if (String.IsNullOrEmpty (newRelationName))
50+
throw new ArgumentNullException("newRelationName");
4951
this.relation = relation;
5052
this.newRelationName = newRelationName;
5153
}
@@ -114,7 +116,7 @@ public override bool Equals (Relation other)
114116
/// </returns>
115117
public override int GetHashCode ()
116118
{
117-
return this.relation.GetHashCode () ^ this.newRelationName.GetHashCode ();
119+
return this.relation.GetHashCode () ^ this.newRelationName.GetHashCode () ^ this.Name.GetHashCode ();
118120
}
119121

120122
/// <summary>
@@ -149,17 +151,16 @@ public override TResult Accept<TResult> (IVisitor<TResult> visitor, IVisitContex
149151
public bool Equals (Rename other)
150152
{
151153
if (null == other) return false;
152-
return this.relation.Equals (other.relation) && this.newRelationName.Equals (other.newRelationName);
154+
return this.relation.Equals (other.relation) && this.newRelationName.Equals (other.newRelationName)
155+
&& this.Name.Equals (other.Name);
153156
}
154157
#endregion
155158

156-
private static string getDefaultName(Relation relation, string newRelationName)
159+
private static string getDefaultName(Relation relation)
157160
{
158161
if(null == relation)
159162
throw new ArgumentNullException("relation");
160-
if(string.IsNullOrEmpty(newRelationName))
161-
throw new ArgumentNullException("newRelationName");
162-
return string.Format ("{0} as {1}", relation.Name, newRelationName);
163+
return relation.Name;
163164
}
164165
}
165166
}

Code/UnitTests/Epic.Query.UnitTests/Relational/Operations/ProjectionQA.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ public void Initialize_WithFakeArguments_Works()
7575
Assert.IsTrue (firstProjection.Attributes.SequenceEqual (attributes));
7676
Assert.IsTrue (firstProjection.Attributes.SequenceEqual (secondProjection.Attributes));
7777

78+
Assert.IsTrue (firstProjection.Name.Equals (table.Name));
7879
Assert.IsTrue (secondProjection.Name.Equals (operationName));
7980
Assert.IsFalse (firstProjection.Equals (secondProjection));
8081
}

Code/UnitTests/Epic.Query.UnitTests/Relational/Operations/RenameQA.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,9 @@ public void Initialize_WithFakeArguments_Works()
6969
Assert.IsTrue (firstRename.NewRelationName.Equals (newRelationName));
7070
Assert.IsTrue (firstRename.NewRelationName.Equals (secondRename.NewRelationName));
7171

72+
Assert.IsTrue (firstRename.Name.Equals (table.Name));
7273
Assert.IsTrue (secondRename.Name.Equals (operationName));
73-
Assert.IsTrue (firstRename.Equals (secondRename));
74+
Assert.IsFalse (firstRename.Equals (secondRename));
7475
}
7576

7677
[Test]

Code/UnitTests/Epic.Query.UnitTests/Relational/Operations/SelectionQA.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void Initialize_WithFakeArguments_Works()
7070
Assert.IsTrue (firstSelection.Condition.Equals (predicate));
7171
Assert.IsTrue (firstSelection.Condition.Equals (secondSelection.Condition));
7272

73+
Assert.IsTrue (firstSelection.Name.Equals (table.Name));
7374
Assert.IsTrue (secondSelection.Name.Equals (operationName));
7475
Assert.IsFalse (firstSelection.Equals (secondSelection));
7576
}

0 commit comments

Comments
 (0)