Permalink
Browse files

fixed Sql.In array issue

  • Loading branch information...
1 parent bb0bf4b commit b50df53c961f5273b32859b4ca698feaa2c16409 @tgrassau tgrassau committed Feb 19, 2013
@@ -11,6 +11,15 @@ public void Setup()
{
using (var dbConn = ConnectionString.OpenDbConnection())
{
+ dbConn.DropTable<TypeWithOnDeleteAndUpdateCascade>();
+ dbConn.DropTable<TypeWithOnDeleteSetNull>();
+ dbConn.DropTable<TypeWithOnDeleteSetDefault>();
+ dbConn.DropTable<TypeWithOnDeleteRestrict>();
+ dbConn.DropTable<TypeWithOnDeleteNoAction>();
+ dbConn.DropTable<TypeWithOnDeleteCascade>();
+ dbConn.DropTable<TypeWithSimpleForeignKey>();
+ dbConn.DropTable<ReferencedType>();
+
dbConn.CreateTable<ReferencedType>(true);
}
}
@@ -98,22 +107,6 @@ public void CanCreateForeignWithOnDeleteSetNull()
dbConn.CreateTable<TypeWithOnDeleteSetNull>(true);
}
}
-
- [TestFixtureTearDown]
- public void TearDwon()
- {
- using (var dbConn = ConnectionString.OpenDbConnection())
- {
- dbConn.DropTable<TypeWithOnDeleteAndUpdateCascade>();
- dbConn.DropTable<TypeWithOnDeleteSetNull>();
- dbConn.DropTable<TypeWithOnDeleteSetDefault>();
- dbConn.DropTable<TypeWithOnDeleteRestrict>();
- dbConn.DropTable<TypeWithOnDeleteNoAction>();
- dbConn.DropTable<TypeWithOnDeleteCascade>();
- dbConn.DropTable<TypeWithSimpleForeignKey>();
- dbConn.DropTable<ReferencedType>();
- }
- }
}
public class ReferencedType
@@ -1,4 +1,5 @@
using System;
+using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
@@ -1114,15 +1115,15 @@ protected virtual object VisitSqlMethodCall(MethodCallExpression m)
StringBuilder sIn = new StringBuilder();
foreach (Object e in inArgs)
{
- if (e.GetType().ToString() != "System.Collections.Generic.List`1[System.Object]")
+ if (!typeof(ICollection).IsAssignableFrom(e.GetType()))
{
sIn.AppendFormat("{0}{1}",
sIn.Length > 0 ? "," : "",
OrmLiteConfig.DialectProvider.GetQuotedValue(e, e.GetType()));
}
else
{
- var listArgs = e as IList<Object>;
+ var listArgs = e as ICollection;
foreach (Object el in listArgs)
{
sIn.AppendFormat("{0}{1}",
@@ -101,6 +101,33 @@ public void Can_Select_using_IN()
}
[Test]
+ public void Can_Select_using_IN_using_params()
+ {
+ var visitor = OrmLiteConfig.DialectProvider.ExpressionVisitor<TestType>();
+ visitor.Where(q => Sql.In(q.Id, 1, 2, 3));
+ var target = ConnectionString.OpenDbConnection().Select(visitor);
+ Assert.AreEqual(3, target.Count);
+ }
+
+ [Test]
+ public void Can_Select_using_IN_using_int_array()
+ {
+ var visitor = OrmLiteConfig.DialectProvider.ExpressionVisitor<TestType>();
+ visitor.Where(q => Sql.In(q.Id, new[] {1, 2, 3}));
+ var target = ConnectionString.OpenDbConnection().Select(visitor);
+ Assert.AreEqual(3, target.Count);
+ }
+
+ [Test]
+ public void Can_Select_using_IN_using_object_array()
+ {
+ var visitor = OrmLiteConfig.DialectProvider.ExpressionVisitor<TestType>();
+ visitor.Where(q => Sql.In(q.Id, new object[] { 1, 2, 3 }));
+ var target = ConnectionString.OpenDbConnection().Select(visitor);
+ Assert.AreEqual(3, target.Count);
+ }
+
+ [Test]
public void Can_Select_using_Startswith()
{
var target = ConnectionString.OpenDbConnection().Select<TestType>(q => q.TextCol.StartsWith("asdf"));

0 comments on commit b50df53

Please sign in to comment.