Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit f87159c

Browse files
committed
fix oracle integer converter for unsigned ints
equality expression test for null variable
1 parent e0216b9 commit f87159c

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

src/ServiceStack.OrmLite.Oracle.Tests/OracleParamTests.cs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,41 +35,55 @@ public void ORA_ParamTestInsert()
3535
db.Insert(new ParamTestBo { Id = 2, Double = 0.002, Int = 200, Info = "Two", NullableBool = true, DateTime = dateTimeNow });
3636
db.Insert(new ParamTestBo { Id = 3, Double = 0.003, Int = 300, Info = "Three", NullableBool = false, DateTime = dateTimeNow.AddDays(23) });
3737
db.Insert(new ParamTestBo { Id = 4, Double = 0.004, Int = 400, Info = "Four", NullableBool = null });
38+
db.Insert(new ParamTestBo { Id = 5, Double = 0.005, Int = 500, Info = "Five", NullableBool = null, UInt = uint.MaxValue});
3839

3940
var bo1 = db.Select<ParamTestBo>(q => q.Id == 1).Single();
4041
var bo2 = db.Select<ParamTestBo>(q => q.Id == 2).Single();
4142
var bo3 = db.Select<ParamTestBo>(q => q.Id == 3).Single();
4243
var bo4 = db.Select<ParamTestBo>(q => q.Id == 4).Single();
44+
var bo5 = db.Select<ParamTestBo>(q => q.Id == 5).Single();
4345

4446
Assert.AreEqual(1, bo1.Id);
4547
Assert.AreEqual(2, bo2.Id);
4648
Assert.AreEqual(3, bo3.Id);
4749
Assert.AreEqual(4, bo4.Id);
50+
Assert.AreEqual(5, bo5.Id);
4851

4952
Assert.AreEqual(0.001, bo1.Double);
5053
Assert.AreEqual(0.002, bo2.Double);
5154
Assert.AreEqual(0.003, bo3.Double);
5255
Assert.AreEqual(0.004, bo4.Double);
56+
Assert.AreEqual(0.005, bo5.Double);
5357

5458
Assert.AreEqual(100, bo1.Int);
5559
Assert.AreEqual(200, bo2.Int);
5660
Assert.AreEqual(300, bo3.Int);
5761
Assert.AreEqual(400, bo4.Int);
62+
Assert.AreEqual(500, bo5.Int);
5863

5964
Assert.AreEqual("One", bo1.Info);
6065
Assert.AreEqual("Two", bo2.Info);
6166
Assert.AreEqual("Three", bo3.Info);
6267
Assert.AreEqual("Four", bo4.Info);
68+
Assert.AreEqual("Five", bo5.Info);
6369

6470
Assert.AreEqual(null, bo1.NullableBool);
6571
Assert.AreEqual(true, bo2.NullableBool);
6672
Assert.AreEqual(false, bo3.NullableBool);
6773
Assert.AreEqual(null, bo4.NullableBool);
74+
Assert.AreEqual(null, bo5.NullableBool);
6875

6976
Assert.AreEqual(dateTimeNow, bo1.DateTime);
7077
Assert.AreEqual(dateTimeNow, bo2.DateTime);
7178
Assert.AreEqual(dateTimeNow.AddDays(23), bo3.DateTime);
7279
Assert.AreEqual(null, bo4.DateTime);
80+
Assert.AreEqual(null, bo5.DateTime);
81+
82+
Assert.AreEqual(null, bo1.UInt);
83+
Assert.AreEqual(null, bo2.UInt);
84+
Assert.AreEqual(null, bo3.UInt);
85+
Assert.AreEqual(null, bo4.UInt);
86+
Assert.AreEqual(uint.MaxValue, bo5.UInt);
7387
}
7488
}
7589

@@ -171,10 +185,11 @@ public void ORA_ParamTestSelectLambda()
171185
LoadParamTestBo(db);
172186

173187
//select multiple items
174-
Assert.AreEqual(2, db.Select<ParamTestBo>(q => q.NullableBool == null).Count);
175-
Assert.AreEqual(2, db.Select<ParamTestBo>(q => q.NullableBool == null).Count);
188+
Assert.AreEqual(3, db.Select<ParamTestBo>(q => q.NullableBool == null).Count);
176189
Assert.AreEqual(1, db.Select<ParamTestBo>(q => q.NullableBool == true).Count);
177190
Assert.AreEqual(1, db.Select<ParamTestBo>(q => q.NullableBool == false).Count);
191+
Assert.AreEqual(1, db.Select<ParamTestBo>(q => q.UInt == uint.MaxValue).Count);
192+
Assert.AreEqual(4, db.Select<ParamTestBo>(q => q.UInt == null).Count);
178193

179194
Assert.AreEqual(1, db.Select<ParamTestBo>(q => q.Info == "Two").Count);
180195
Assert.AreEqual(1, db.Select<ParamTestBo>(q => q.Int == 300).Count);
@@ -188,6 +203,7 @@ private void LoadParamTestBo(IDbConnection db)
188203
db.Insert(new ParamTestBo { Id = 2, Double = 0.002, Int = 200, Info = "Two", NullableBool = true });
189204
db.Insert(new ParamTestBo { Id = 3, Double = 0.003, Int = 300, Info = "Three", NullableBool = false });
190205
db.Insert(new ParamTestBo { Id = 4, Double = 0.004, Int = 400, Info = "Four", NullableBool = null });
206+
db.Insert(new ParamTestBo { Id = 5, Double = 0.005, Int = 500, Info = "Five", NullableBool = null, UInt = uint.MaxValue});
191207
}
192208

193209
[Test]
@@ -1156,6 +1172,7 @@ public class ParamTestBo
11561172
public double Double { get; set; }
11571173
public bool? NullableBool { get; set; }
11581174
public DateTime? DateTime { get; set; }
1175+
public uint? UInt { get; set; }
11591176
}
11601177

11611178
public class ParamRelBo

src/ServiceStack.OrmLite.Oracle/Converters/OracleIntegerConverters.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ public class OracleUInt16Converter : UInt16Converter
2323
{
2424
public override DbType DbType
2525
{
26-
get { return DbType.Int16; }
26+
get { return DbType.Decimal; }
2727
}
2828
}
2929

3030
public class OracleUInt32Converter : UInt32Converter
3131
{
3232
public override DbType DbType
3333
{
34-
get { return DbType.Int32; }
34+
get { return DbType.Decimal; }
3535
}
3636

3737
public override string ColumnDefinition
@@ -44,7 +44,7 @@ public class OracleUInt64Converter : UInt64Converter
4444
{
4545
public override DbType DbType
4646
{
47-
get { return DbType.Int64; }
47+
get { return DbType.Decimal; }
4848
}
4949

5050
public override string ColumnDefinition

tests/ServiceStack.OrmLite.Tests/Expression/EqualityExpressionsTest.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,27 @@ public void Can_select_not_equals_null_espression()
289289
}
290290

291291
// Assume not equal works ;-)
292+
[Test]
293+
public void Can_select_equals_variable_null_expression()
294+
{
295+
object columnValue = null;
296+
297+
var expected = new TestType()
298+
{
299+
IntColumn = 12,
300+
BoolColumn = false,
301+
StringColumn = "test",
302+
NullableCol = new TestType { StringColumn = "sometext" }
303+
};
304+
305+
EstablishContext(10, expected);
306+
307+
var actual = OpenDbConnection().Select<TestType>(q => q.NullableCol == columnValue);
308+
309+
Assert.IsNotNull(actual);
310+
Assert.AreEqual(actual.Count, 10);
311+
CollectionAssert.DoesNotContain(actual, expected);
312+
}
292313
#endregion
293314
}
294315
}

0 commit comments

Comments
 (0)