Skip to content

Commit

Permalink
removed unnecessary type parameter from ISolrQuery
Browse files Browse the repository at this point in the history
git-svn-id: http://solrnet.googlecode.com/svn/trunk@78 66c3f25c-543c-0410-ae2e-6f2ca0bd8c61
  • Loading branch information
mausch committed Feb 26, 2008
1 parent 6ab5629 commit be366a8
Show file tree
Hide file tree
Showing 33 changed files with 224 additions and 309 deletions.
12 changes: 6 additions & 6 deletions SolrNet.DSL.Tests/DSLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void DeleteByQuery() {
Expect.Call(conn.Post("/update", string.Format("<delete><query>{0}</query></delete>", q))).Return("");
}).Verify(delegate {
Solr.Connection = conn;
Solr.Delete.ByQuery(new SolrQuery<TestDocument>(q));
Solr.Delete.ByQuery(new SolrQuery(q));
});
}

Expand All @@ -87,7 +87,7 @@ public void DeleteByQueryString() {
Expect.Call(conn.Post("/update", string.Format("<delete><query>{0}</query></delete>", q))).Return("");
}).Verify(delegate {
Solr.Connection = conn;
Solr.Delete.ByQuery<TestDocument>(q);
Solr.Delete.ByQuery(q);
});
}

Expand Down Expand Up @@ -134,7 +134,7 @@ public void OrderBy2() {
Expect.Call(conn.Get("/select", query)).Repeat.Once().Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString), new SortOrder("id", Order.ASC));
Solr.Query<TestDocument>(new SolrQuery(queryString), new SortOrder("id", Order.ASC));
});
}

Expand All @@ -148,7 +148,7 @@ public void OrderBy2Multiple() {
Expect.Call(conn.Get("/select", query)).Repeat.Once().Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString), new[] {new SortOrder("id", Order.ASC), new SortOrder("name", Order.DESC)});
Solr.Query<TestDocument>(new SolrQuery(queryString), new[] {new SortOrder("id", Order.ASC), new SortOrder("name", Order.DESC)});
});
}

Expand Down Expand Up @@ -335,7 +335,7 @@ public void QueryISolrQuery() {
.Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString));
Solr.Query<TestDocument>(new SolrQuery(queryString));
});
}

Expand All @@ -356,7 +356,7 @@ public void QueryISolrQueryWithPagination() {
.Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString), 10, 20);
Solr.Query<TestDocument>(new SolrQuery(queryString), 10, 20);
});
}

Expand Down
28 changes: 22 additions & 6 deletions SolrNet.DSL.v3.5.Tests/DSLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void DeleteByQuery() {
Expect.Call(conn.Post("/update", string.Format("<delete><query>{0}</query></delete>", q))).Return("");
}).Verify(delegate {
Solr.Connection = conn;
Solr.Delete.ByQuery(new SolrQuery<TestDocument>(q));
Solr.Delete.ByQuery(new SolrQuery(q));
});
}

Expand All @@ -87,7 +87,7 @@ public void DeleteByQueryString() {
Expect.Call(conn.Post("/update", string.Format("<delete><query>{0}</query></delete>", q))).Return("");
}).Verify(delegate {
Solr.Connection = conn;
Solr.Delete.ByQuery<TestDocument>(q);
Solr.Delete.ByQuery(q);
});
}

Expand Down Expand Up @@ -134,7 +134,7 @@ public void OrderBy2() {
Expect.Call(conn.Get("/select", query)).Repeat.Once().Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString), new SortOrder("id", Order.ASC));
Solr.Query<TestDocument>(new SolrQuery(queryString), new SortOrder("id", Order.ASC));
});
}

Expand All @@ -148,7 +148,7 @@ public void OrderBy2Multiple() {
Expect.Call(conn.Get("/select", query)).Repeat.Once().Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString), new[] { new SortOrder("id", Order.ASC), new SortOrder("name", Order.DESC) });
Solr.Query<TestDocument>(new SolrQuery(queryString), new[] { new SortOrder("id", Order.ASC), new SortOrder("name", Order.DESC) });
});
}

Expand Down Expand Up @@ -323,6 +323,22 @@ public void QueryByRangeConcatenable() {
});
}

[Test]
public void QueryByRange_Lambda() {
var mocks = new MockRepository();
var conn = mocks.CreateMock<ISolrConnection>();
With.Mocks(mocks).Expecting(delegate {
var query = new Dictionary<string, string> { { "q", "Id:[123 TO 456]" } };
Expect.Call(conn.Get("/select", query))
.Repeat.Once()
.Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query<TestDocumentWithId>().ByRange(x => x.Id >= 123 && x.Id <= 456).Run();
});
}


[Test]
public void QueryByRangeExclusive() {
var mocks = new MockRepository();
Expand Down Expand Up @@ -365,7 +381,7 @@ public void QueryISolrQuery() {
.Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString));
Solr.Query<TestDocument>(new SolrQuery(queryString));
});
}

Expand All @@ -386,7 +402,7 @@ public void QueryISolrQueryWithPagination() {
.Return(response);
}).Verify(delegate {
Solr.Connection = conn;
Solr.Query(new SolrQuery<TestDocument>(queryString), 10, 20);
Solr.Query<TestDocument>(new SolrQuery(queryString), 10, 20);
});
}

Expand Down
4 changes: 4 additions & 0 deletions SolrNet.DSL.v3.5/DSLQuery35.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public IDSLQueryRange<T> ByRange<RT>(Expression<Func<T, object>> f, RT from, RT
}
}

public IDSLQueryRange<T> ByRange(Expression<Func<T, object>> f) {
throw new NotImplementedException();
}

public IDSLQueryBy<T> By(Expression<Func<T, object>> f) {
try {
var exp = f.Body as UnaryExpression;
Expand Down
1 change: 1 addition & 0 deletions SolrNet.DSL.v3.5/IDSLQuery35.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
namespace SolrNet.DSL.v3._5 {
public interface IDSLQuery35<T> : IDSLQuery<T> where T : ISolrDocument, new() {
IDSLQueryRange<T> ByRange<RT>(Expression<Func<T, object>> f, RT from, RT to);
IDSLQueryRange<T> ByRange(Expression<Func<T, object>> f);
IDSLQueryBy<T> By(Expression<Func<T, object>> f);
}
}
16 changes: 8 additions & 8 deletions SolrNet.DSL.v3.5/Solr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public static void Optimize() {
DSL.Solr.Optimize();
}

public static ISolrQueryResults<T> Query<T>(ISolrQuery<T> q) where T : ISolrDocument, new() {
return DSL.Solr.Query(q);
public static ISolrQueryResults<T> Query<T>(ISolrQuery q) where T : ISolrDocument, new() {
return DSL.Solr.Query<T>(q);
}

public static ISolrQueryResults<T> Query<T>(string q) where T : ISolrDocument, new() {
return DSL.Solr.Query<T>(q);
}

public static ISolrQueryResults<T> Query<T>(ISolrQuery<T> q, int start, int rows) where T : ISolrDocument, new() {
return DSL.Solr.Query(q, start, rows);
public static ISolrQueryResults<T> Query<T>(ISolrQuery q, int start, int rows) where T : ISolrDocument, new() {
return DSL.Solr.Query<T>(q, start, rows);
}

public static ISolrQueryResults<T> Query<T>(string q, int start, int rows) where T : ISolrDocument, new() {
Expand All @@ -48,12 +48,12 @@ public static void Optimize(bool waitFlush, bool waitSearcher) {
DSL.Solr.Optimize(waitFlush, waitSearcher);
}

public static ISolrQueryResults<T> Query<T>(SolrQuery<T> query, SortOrder order) where T : ISolrDocument, new() {
return DSL.Solr.Query(query, order);
public static ISolrQueryResults<T> Query<T>(SolrQuery query, SortOrder order) where T : ISolrDocument, new() {
return DSL.Solr.Query<T>(query, order);
}

public static ISolrQueryResults<T> Query<T>(SolrQuery<T> query, ICollection<SortOrder> orders) where T : ISolrDocument, new() {
return DSL.Solr.Query(query, orders);
public static ISolrQueryResults<T> Query<T>(SolrQuery query, ICollection<SortOrder> orders) where T : ISolrDocument, new() {
return DSL.Solr.Query<T>(query, orders);
}

public static readonly string SolrConnectionKey = DSL.Solr.SolrConnectionKey;
Expand Down
4 changes: 2 additions & 2 deletions SolrNet.DSL/DSLQuery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace SolrNet.DSL {
public class DSLQuery<T> : DSLRun<T>, IDSLQuery<T> where T : ISolrDocument, new() {
public DSLQuery(ISolrConnection connection) : base(connection) {}

public DSLQuery(ISolrConnection connection, ISolrQuery<T> query) : base(connection, query) {}
public DSLQuery(ISolrConnection connection, ISolrQuery query) : base(connection, query) {}

public IDSLQueryRange<T> ByRange<RT>(string fieldName, RT from, RT to) {
return new DSLQueryRange<T, RT>(connection, query, fieldName, from, to);
Expand All @@ -14,7 +14,7 @@ public IDSLQueryBy<T> By(string fieldName) {

public IDSLQuery<T> ByExample(T doc) {
return new DSLQuery<T>(connection,
new SolrMultipleCriteriaQuery<T>(new ISolrQuery<T>[] {
new SolrMultipleCriteriaQuery<T>(new ISolrQuery[] {
query,
new SolrQueryByExample<T>(doc)
}));
Expand Down
6 changes: 3 additions & 3 deletions SolrNet.DSL/DSLQueryBetween.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ namespace SolrNet.DSL {
public class DSLQueryBetween<T, RT> : IDSLQueryBetween<T, RT> where T : ISolrDocument, new() {
private readonly string fieldName;
private readonly ISolrConnection connection;
private readonly ISolrQuery<T> query;
private readonly ISolrQuery query;
private readonly RT from;

public DSLQueryBetween(string fieldName, ISolrConnection connection, ISolrQuery<T> query, RT from) {
public DSLQueryBetween(string fieldName, ISolrConnection connection, ISolrQuery query, RT from) {
this.fieldName = fieldName;
this.connection = connection;
this.query = query;
Expand All @@ -15,7 +15,7 @@ public DSLQueryBetween(string fieldName, ISolrConnection connection, ISolrQuery<
public IDSLQuery<T> And(RT i) {
return new DSLQuery<T>(connection,
new SolrMultipleCriteriaQuery<T>(
new ISolrQuery<T>[] {
new ISolrQuery[] {
query,
new SolrQueryByRange<T, RT>(fieldName, from, i)
}));
Expand Down
6 changes: 3 additions & 3 deletions SolrNet.DSL/DSLQueryBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ namespace SolrNet.DSL {
public class DSLQueryBy<T> : IDSLQueryBy<T> where T : ISolrDocument, new() {
private readonly string fieldName;
private readonly ISolrConnection connection;
private readonly ISolrQuery<T> query;
private readonly ISolrQuery query;

public DSLQueryBy(string fieldName, ISolrConnection connection, ISolrQuery<T> query) {
public DSLQueryBy(string fieldName, ISolrConnection connection, ISolrQuery query) {
this.fieldName = fieldName;
this.connection = connection;
this.query = query;
}

public IDSLQuery<T> Is(string s) {
return new DSLQuery<T>(connection,
new SolrMultipleCriteriaQuery<T>(new ISolrQuery<T>[] {
new SolrMultipleCriteriaQuery<T>(new ISolrQuery[] {
query,
new SolrQueryByField<T>(fieldName, s)
}));
Expand Down
10 changes: 5 additions & 5 deletions SolrNet.DSL/DSLQueryRange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ namespace SolrNet.DSL {
private readonly string fieldName;
private readonly RT from;
private readonly RT to;
private readonly ISolrQuery<T> prevQuery;
private readonly ISolrQuery prevQuery;

public DSLQueryRange(ISolrConnection connection, ISolrQuery<T> query, string fieldName, RT from, RT to) : base(connection) {
this.query = new SolrMultipleCriteriaQuery<T>(new ISolrQuery<T>[] {
public DSLQueryRange(ISolrConnection connection, ISolrQuery query, string fieldName, RT from, RT to) : base(connection) {
this.query = new SolrMultipleCriteriaQuery<T>(new ISolrQuery[] {
query,
new SolrQueryByRange<T, RT>(fieldName, from, to)
});
Expand All @@ -16,8 +16,8 @@ public DSLQueryRange(ISolrConnection connection, ISolrQuery<T> query, string fie
this.to = to;
}

private ISolrQuery<T> buildFinalQuery(bool inclusive) {
return new SolrMultipleCriteriaQuery<T>(new ISolrQuery<T>[] {
private ISolrQuery buildFinalQuery(bool inclusive) {
return new SolrMultipleCriteriaQuery<T>(new ISolrQuery[] {
prevQuery,
new SolrQueryByRange<T, RT>(fieldName, from, to, inclusive)
});
Expand Down
6 changes: 3 additions & 3 deletions SolrNet.DSL/DSLRun.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@ namespace SolrNet.DSL {
public class DSLRun<T> : IDSLRun<T> where T : ISolrDocument, new() {
private readonly ICollection<SortOrder> order = new List<SortOrder>();
protected ISolrConnection connection;
protected ISolrQuery<T> query;
protected ISolrQuery query;

public DSLRun(ISolrConnection connection) {
this.connection = connection;
}

public DSLRun(ISolrConnection connection, ISolrQuery<T> query) {
public DSLRun(ISolrConnection connection, ISolrQuery query) {
this.connection = connection;
this.query = query;
}

public DSLRun(ISolrConnection connection, ISolrQuery<T> query, ICollection<SortOrder> order) {
public DSLRun(ISolrConnection connection, ISolrQuery query, ICollection<SortOrder> order) {
this.connection = connection;
this.query = query;
this.order = order;
Expand Down
10 changes: 5 additions & 5 deletions SolrNet.DSL/DeleteBy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ public DeleteBy(ISolrConnection connection) {
}

public void ById(string id) {
DeleteCommand cmd = new DeleteCommand(new DeleteByIdParam(id));
var cmd = new DeleteCommand(new DeleteByIdParam(id));
cmd.Execute(connection);
}

public void ByQuery<T>(ISolrQuery<T> q) where T : ISolrDocument {
DeleteCommand cmd = new DeleteCommand(new DeleteByQueryParam<T>(q));
public void ByQuery(ISolrQuery q) {
var cmd = new DeleteCommand(new DeleteByQueryParam(q));
cmd.Execute(connection);
}

public void ByQuery<T>(string q) where T : ISolrDocument {
ByQuery(new SolrQuery<T>(q));
public void ByQuery(string q) {
ByQuery(new SolrQuery(q));
}
}
}
10 changes: 5 additions & 5 deletions SolrNet.DSL/Solr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,21 +60,21 @@ public static void Add<T>(IEnumerable<T> documents) where T : ISolrDocument {
return q.Execute(start, rows);
}

public static ISolrQueryResults<T> Query<T>(ISolrQuery<T> q) where T : ISolrDocument, new() {
public static ISolrQueryResults<T> Query<T>(ISolrQuery q) where T : ISolrDocument, new() {
var queryExecuter = new SolrQueryExecuter<T>(Connection, q.Query);
return queryExecuter.Execute();
}

public static ISolrQueryResults<T> Query<T>(ISolrQuery<T> q, int start, int rows) where T : ISolrDocument, new() {
public static ISolrQueryResults<T> Query<T>(ISolrQuery q, int start, int rows) where T : ISolrDocument, new() {
var queryExecuter = new SolrQueryExecuter<T>(Connection, q.Query);
return queryExecuter.Execute(start, rows);
}

public static ISolrQueryResults<T> Query<T>(SolrQuery<T> query, SortOrder order) where T : ISolrDocument, new() {
return Query(query, new[] {order});
public static ISolrQueryResults<T> Query<T>(SolrQuery query, SortOrder order) where T : ISolrDocument, new() {
return Query<T>(query, new[] {order});
}

public static ISolrQueryResults<T> Query<T>(SolrQuery<T> query, ICollection<SortOrder> orders) where T : ISolrDocument, new() {
public static ISolrQueryResults<T> Query<T>(SolrQuery query, ICollection<SortOrder> orders) where T : ISolrDocument, new() {
var queryExecuter = new SolrQueryExecuter<T>(Connection, query.Query) {OrderBy = orders};
return queryExecuter.Execute();
}
Expand Down
Loading

0 comments on commit be366a8

Please sign in to comment.