Skip to content

Commit

Permalink
Removed some ambiguous Where overloads
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Sep 16, 2020
1 parent 61fd312 commit 414884e
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 202 deletions.
76 changes: 24 additions & 52 deletions SequelNet/Sql/Query/Wheres.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ public Query Where(string columnName, WhereComparison comparison, object value)
return Where(new Where(WhereCondition.AND, columnName, ValueObjectType.ColumnName, comparison, value, ValueObjectType.Value));
}

public Query Where(string literalExpression)
{
return Where(new Where(WhereCondition.AND, literalExpression, ValueObjectType.Literal, WhereComparison.None, null, ValueObjectType.Literal));
}

public Query Where(IPhrase phrase)
{
return Where(new Where(WhereCondition.AND, phrase, ValueObjectType.Value, WhereComparison.None, null, ValueObjectType.Literal));
Expand All @@ -60,18 +55,6 @@ public Query Where(string tableName, string columnName, WhereComparison comparis
return Where(new Where(WhereCondition.AND, tableName, columnName, comparison, otherTableName, otherColumnName));
}

public Query Where(string tableName, string columnName, object betweenValue, object andValue)
{
Where where = new Where(WhereCondition.AND, columnName, ValueObjectType.ColumnName, betweenValue, ValueObjectType.Value, andValue, ValueObjectType.Value);
where.FirstTableName = tableName;
return Where(where);
}

public Query Where(string columnName, object betweenValue, object andValue)
{
return Where(new Where(WhereCondition.AND, columnName, ValueObjectType.ColumnName, betweenValue, ValueObjectType.Value, andValue, ValueObjectType.Value));
}

public Query Where(IPhrase phrase, WhereComparison comparison, string tableName, string columnName)
{
return Where(new Where(WhereCondition.AND, phrase, comparison, tableName, columnName));
Expand All @@ -92,6 +75,14 @@ public Query Where(Query query, WhereComparison comparison, object value, ValueO
return Where(new Where(WhereCondition.AND, query, comparison, value, valueType));
}

public Query Where(
object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
return Where(new Where(WhereCondition.AND, aValue, aType, betweenValue, betweenType, andValue, andType));
}

public Query AND(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
{
return Where(new Where(WhereCondition.AND, thisObject, thisObjectType, comparison, thatObject, thatObjectType));
Expand All @@ -107,11 +98,6 @@ public Query AND(string columnName, WhereComparison comparison, object value)
return Where(new Where(WhereCondition.AND, columnName, ValueObjectType.ColumnName, comparison, value, ValueObjectType.Value));
}

public Query AND(string literalExpression)
{
return Where(new Where(WhereCondition.AND, literalExpression, ValueObjectType.Literal, WhereComparison.None, null, ValueObjectType.Literal));
}

public Query AND(IPhrase phrase)
{
return Where(new Where(WhereCondition.AND, phrase, ValueObjectType.Value, WhereComparison.None, null, ValueObjectType.Literal));
Expand All @@ -132,19 +118,6 @@ public Query AND(string tableName, string columnName, WhereComparison comparison
return Where(new Where(WhereCondition.AND, tableName, columnName, comparison, otherTableName, otherColumnName));
}

public Query AND(string tableName, string columnName, object betweenValue, object andValue)
{
Where where = new Where(WhereCondition.AND, columnName, ValueObjectType.ColumnName, betweenValue, ValueObjectType.Value, andValue, ValueObjectType.Value);
where.FirstTableName = tableName;
return Where(where);
}

public Query AND(string columnName, object betweenValue, object andValue)
{
Where where = new Where(WhereCondition.AND, columnName, ValueObjectType.ColumnName, betweenValue, ValueObjectType.Value, andValue, ValueObjectType.Value);
return Where(where);
}

public Query AND(IPhrase phrase, WhereComparison comparison, string tableName, string columnName)
{
return Where(new Where(WhereCondition.AND, phrase, comparison, tableName, columnName));
Expand All @@ -165,6 +138,14 @@ public Query AND(Query query, WhereComparison comparison, object value, ValueObj
return Where(new Where(WhereCondition.AND, query, comparison, value, valueType));
}

public Query AND(
object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
return Where(new Where(WhereCondition.AND, aValue, aType, betweenValue, betweenType, andValue, andType));
}

public Query OR(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
{
return Where(new Where(WhereCondition.OR, thisObject, thisObjectType, comparison, thatObject, thatObjectType));
Expand All @@ -180,11 +161,6 @@ public Query OR(string columnName, WhereComparison comparison, object value)
return Where(new Where(WhereCondition.OR, columnName, ValueObjectType.ColumnName, comparison, value, ValueObjectType.Value));
}

public Query OR(string literalExpression)
{
return Where(new Where(WhereCondition.OR, literalExpression, ValueObjectType.Literal, WhereComparison.None, null, ValueObjectType.Literal));
}

public Query OR(IPhrase phrase)
{
return Where(new Where(WhereCondition.OR, phrase, ValueObjectType.Value, WhereComparison.None, null, ValueObjectType.Literal));
Expand All @@ -205,18 +181,6 @@ public Query OR(string tableName, string columnName, WhereComparison comparison,
return Where(new Where(WhereCondition.OR, tableName, columnName, comparison, otherTableName, otherColumnName));
}

public Query OR(string tableName, string columnName, object betweenValue, object andValue)
{
Where where = new Where(WhereCondition.OR, columnName, ValueObjectType.ColumnName, betweenValue, ValueObjectType.Value, andValue, ValueObjectType.Value);
where.FirstTableName = tableName;
return Where(where);
}

public Query OR(string columnName, object betweenValue, object andValue)
{
return Where(new Where(WhereCondition.OR, columnName, ValueObjectType.ColumnName, betweenValue, ValueObjectType.Value, andValue, ValueObjectType.Value));
}

public Query OR(IPhrase phrase, WhereComparison comparison, string tableName, string columnName)
{
return Where(new Where(WhereCondition.OR, phrase, comparison, tableName, columnName));
Expand All @@ -237,6 +201,14 @@ public Query OR(Query query, WhereComparison comparison, object value, ValueObje
return Where(new Where(WhereCondition.OR, query, comparison, value, valueType));
}

public Query OR(
object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
return Where(new Where(WhereCondition.OR, aValue, aType, betweenValue, betweenType, andValue, andType));
}

public Query AddFromList(WhereList whereList)
{
if (_ListWhere == null) _ListWhere = new WhereList();
Expand Down
46 changes: 0 additions & 46 deletions SequelNet/Sql/QueryKeywords/Join.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@ public JoinColumnPair(object value, string rightColumn)
this.Add(new Where(WhereCondition.AND, RIGHT_TABLE_PLACEHOLDER_ID, rightColumn, WhereComparison.EqualsTo, value));
}

public JoinColumnPair(object value, bool literalValue, string rightColumn)
{
Where w = new Where(WhereCondition.AND, RIGHT_TABLE_PLACEHOLDER_ID, rightColumn, WhereComparison.EqualsTo, value);
if (literalValue) w.SecondType = ValueObjectType.Literal;
this.Add(w);
}

public JoinColumnPair(string leftTableNameOrAlias, string leftColumn, object value, bool literalValue)
{
Where w = new Where(WhereCondition.AND, leftTableNameOrAlias, leftColumn, WhereComparison.EqualsTo, value);
if (literalValue) w.SecondType = ValueObjectType.Literal;
this.Add(w);
}

public JoinColumnPair AND(TableSchema leftTableSchema, string leftColumn, string rightColumn)
{
this.Add(new Where(WhereCondition.AND, leftTableSchema.Name, leftColumn, WhereComparison.EqualsTo, RIGHT_TABLE_PLACEHOLDER_ID, rightColumn));
Expand All @@ -60,22 +46,6 @@ public JoinColumnPair AND(object value, string rightColumn)
return this;
}

public JoinColumnPair AND(object value, bool literalValue, string rightColumn)
{
Where w = new Where(WhereCondition.AND, RIGHT_TABLE_PLACEHOLDER_ID, rightColumn, WhereComparison.EqualsTo, value);
if (literalValue) w.SecondType = ValueObjectType.Literal;
this.Add(w);
return this;
}

public JoinColumnPair AND(string leftTableNameOrAlias, string leftColumn, object value, bool literalValue)
{
Where w = new Where(WhereCondition.AND, leftTableNameOrAlias, leftColumn, WhereComparison.EqualsTo, value);
if (literalValue) w.SecondType = ValueObjectType.Literal;
this.Add(w);
return this;
}

public new JoinColumnPair AND(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
{
base.AND(thisObject, thisObjectType, comparison, thatObject, thatObjectType);
Expand Down Expand Up @@ -142,22 +112,6 @@ public JoinColumnPair OR(object value, string rightColumn)
return this;
}

public JoinColumnPair OR(object value, bool literalValue, string rightColumn)
{
Where w = new Where(WhereCondition.OR, RIGHT_TABLE_PLACEHOLDER_ID, rightColumn, WhereComparison.EqualsTo, value);
if (literalValue) w.SecondType = ValueObjectType.Literal;
this.Add(w);
return this;
}

public JoinColumnPair OR(string leftTableNameOrAlias, string leftColumn, object value, bool literalValue)
{
Where w = new Where(WhereCondition.OR, leftTableNameOrAlias, leftColumn, WhereComparison.EqualsTo, value);
if (literalValue) w.SecondType = ValueObjectType.Literal;
this.Add(w);
return this;
}

public new JoinColumnPair OR(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
{
base.OR(thisObject, thisObjectType, comparison, thatObject, thatObjectType);
Expand Down
78 changes: 28 additions & 50 deletions SequelNet/Sql/QueryKeywords/Where.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,17 @@ public Where(object thisObject, ValueObjectType thisObjectType, WhereComparison
SecondType = thatObjectType;
}

public Where(object thisObject, ValueObjectType thisObjectType,
object betweenThisObject, ValueObjectType betweenThisObjectType,
object andThatObject, ValueObjectType andThatObjectType)
public Where(object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
Comparison = WhereComparison.Between;
First = thisObject;
FirstType = thisObjectType;
Second = betweenThisObject;
SecondType = betweenThisObjectType;
Third = andThatObject;
ThirdType = andThatObjectType;
First = aValue;
FirstType = aType;
Second = betweenValue;
SecondType = betweenType;
Third = andValue;
ThirdType = andType;
}

public Where(string tableName, string columnName,
Expand Down Expand Up @@ -191,18 +191,18 @@ public Where(WhereCondition condition, object thisObject, ValueObjectType thisOb
}

public Where(WhereCondition condition,
object thisObject, ValueObjectType thisObjectType,
object betweenThisObject, ValueObjectType betweenThisObjectType,
object andThatObject, ValueObjectType andThatObjectType)
object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
Condition = condition;
Comparison = WhereComparison.Between;
First = thisObject;
FirstType = thisObjectType;
Second = betweenThisObject;
SecondType = betweenThisObjectType;
Third = andThatObject;
ThirdType = andThatObjectType;
First = aValue;
FirstType = aType;
Second = betweenValue;
SecondType = betweenType;
Third = andValue;
ThirdType = andType;
}

public Where(WhereCondition condition,
Expand Down Expand Up @@ -564,13 +564,6 @@ public WhereList AND(string columnName, WhereComparison comparison, object colum
return wl.AND(columnName, comparison, columnValue);
}

public WhereList AND(string literalExpression)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(literalExpression);
}

public WhereList AND(IPhrase phrase)
{
var wl = new WhereList();
Expand Down Expand Up @@ -620,18 +613,14 @@ public WhereList AND(string tableName, string columnName, WhereComparison compar
return wl.AND(tableName, columnName, comparison, otherTableName, otherColumnName);
}

public WhereList AND(string tableName, string columnName, object betweenValue, object andValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(tableName, columnName, betweenValue, andValue);
}

public WhereList AND(string columnName, object betweenValue, object andValue)
public WhereList AND(
object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
var wl = new WhereList();
wl.Add(this);
return wl.AND(columnName, betweenValue, andValue);
return wl.AND(aValue, aType, betweenValue, betweenType, andValue, andType);
}

public WhereList OR(object thisObject, ValueObjectType thisObjectType, WhereComparison comparison, object thatObject, ValueObjectType thatObjectType)
Expand All @@ -655,13 +644,6 @@ public WhereList OR(string columnName, WhereComparison comparison, object column
return wl.OR(columnName, comparison, columnValue);
}

public WhereList OR(string literalExpression)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(literalExpression);
}

public WhereList OR(IPhrase phrase)
{
var wl = new WhereList();
Expand Down Expand Up @@ -711,18 +693,14 @@ public WhereList OR(string tableName, string columnName, WhereComparison compari
return wl.OR(tableName, columnName, comparison, otherTableName, otherColumnName);
}

public WhereList OR(string tableName, string columnName, object betweenValue, object andValue)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(tableName, columnName, betweenValue, andValue);
}

public WhereList OR(string columnName, object betweenValue, object andValue)
public WhereList OR(
object aValue, ValueObjectType aType,
object betweenValue, ValueObjectType betweenType,
object andValue, ValueObjectType andType)
{
var wl = new WhereList();
wl.Add(this);
return wl.OR(columnName, betweenValue, andValue);
return wl.OR(aValue, aType, betweenValue, betweenType, andValue, andType);
}

#endregion
Expand Down
Loading

0 comments on commit 414884e

Please sign in to comment.