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

Commit 3814eb7

Browse files
author
TroyDycavinu-AI
committed
Fixed Oracle Provider Bugs
- Removed the OracleDoubleConverter - Removed dependency on timestampConverter to always set the current thread's timestamp format - Wrapped the OracleConnection, OracleDbReader, OracleCommand and OracleValue objects to hide their functionality and make it more consistent with the .net equivalents - Fixed issues where it did not work with mini-profiler - Fixed issues with ordering of parameters by setting BindByName = true - Fixed Oracle specific syntax issue for COUNT - Fixed an issue with inconsistencies for quoted table names - Fixed inconsistencies where enums where sometimes expecting the string and other times expecting the integer value - Fixed an issue with flag enums - Added "INDEX" to the reserved word for ORACLE - Fixed some unit tests that did not work for ORACLE Note: there is still an issue with paging and the way ORACLE handles ROWNUMs
1 parent 3587e92 commit 3814eb7

23 files changed

+828
-271
lines changed

src/ServiceStack.OrmLite.Oracle.Tests/ServiceStack.OrmLite.Oracle.Tests.csproj

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
<Reference Include="ServiceStack">
5959
<HintPath>..\..\lib\ServiceStack.dll</HintPath>
6060
</Reference>
61+
<Reference Include="ServiceStack.Client">
62+
<HintPath>..\..\lib\ServiceStack.Client.dll</HintPath>
63+
</Reference>
6164
<Reference Include="ServiceStack.Common">
6265
<HintPath>..\..\lib\ServiceStack.Common.dll</HintPath>
6366
</Reference>
@@ -78,6 +81,9 @@
7881
<Reference Include="System.Xml" />
7982
</ItemGroup>
8083
<ItemGroup>
84+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\CaptureSqlFilterTests.cs">
85+
<Link>CaptureSqlFilterTests.cs</Link>
86+
</Compile>
8187
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\CompositeKeyTests.cs">
8288
<Link>CompositeKeyTests.cs</Link>
8389
</Compile>
@@ -96,6 +102,9 @@
96102
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\AdditiveExpressionsTest.cs">
97103
<Link>Expression\AdditiveExpressionsTest.cs</Link>
98104
</Compile>
105+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\ComplexJoinTests.cs">
106+
<Link>Expression\ComplexJoinTests.cs</Link>
107+
</Compile>
99108
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\ConditionalExpressionTest.cs">
100109
<Link>Expression\ConditionalExpressionTest.cs</Link>
101110
</Compile>
@@ -111,6 +120,12 @@
111120
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\ExpressionUsingCustomSerializedEnumTests.cs">
112121
<Link>Expression\ExpressionUsingCustomSerializedEnumTests.cs</Link>
113122
</Compile>
123+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\FromExpressionTests.cs">
124+
<Link>Expression\FromExpressionTests.cs</Link>
125+
</Compile>
126+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\GenericTableExpressions.cs">
127+
<Link>Expression\GenericTableExpressions.cs</Link>
128+
</Compile>
114129
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\LogicalExpressionsTest.cs">
115130
<Link>Expression\LogicalExpressionsTest.cs</Link>
116131
</Compile>
@@ -144,6 +159,27 @@
144159
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Expression\UnaryExpressionsTest.cs">
145160
<Link>Expression\UnaryExpressionsTest.cs</Link>
146161
</Compile>
162+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\ComplexJoinWithAlias.cs">
163+
<Link>Issues\ComplexJoinWithAlias.cs</Link>
164+
</Compile>
165+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\MismatchSchemaTests.cs">
166+
<Link>Issues\MismatchSchemaTests.cs</Link>
167+
</Compile>
168+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\MultiFieldReferenceTests.cs">
169+
<Link>Issues\MultiFieldReferenceTests.cs</Link>
170+
</Compile>
171+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\MultithreadingIssueTests.cs">
172+
<Link>Issues\MultithreadingIssueTests.cs</Link>
173+
</Compile>
174+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\SchemaTests.cs">
175+
<Link>Issues\SchemaTests.cs</Link>
176+
</Compile>
177+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\SelectDistinctTests.cs">
178+
<Link>Issues\SelectDistinctTests.cs</Link>
179+
</Compile>
180+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\Issues\SelectIntoTests.cs">
181+
<Link>Issues\SelectIntoTests.cs</Link>
182+
</Compile>
147183
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\JoinSqlBuilderTests.cs">
148184
<Link>JoinSqlBuilderTests.cs</Link>
149185
</Compile>
@@ -312,6 +348,9 @@
312348
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\SqlFormatTests.cs">
313349
<Link>SqlFormatTests.cs</Link>
314350
</Compile>
351+
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\StringSerializerTests.cs">
352+
<Link>StringSerializerTests.cs</Link>
353+
</Compile>
315354
<Compile Include="..\..\tests\ServiceStack.OrmLite.Tests\TestHelpers.cs">
316355
<Link>TestHelpers.cs</Link>
317356
</Compile>

src/ServiceStack.OrmLite.Oracle/Oracle.cs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
using System;
2+
using System.Data;
3+
using System.Data.Common;
4+
using System.Reflection;
5+
6+
namespace ServiceStack.OrmLite.Oracle
7+
{
8+
public class OracleCommand : DbCommand
9+
{
10+
private readonly DbCommand _command;
11+
12+
private readonly Lazy<MethodInfo> _setBindByNameMethod;
13+
private bool _bindByNameIsSet;
14+
public OracleCommand(DbCommand command)
15+
{
16+
if (command == null)
17+
throw new ArgumentNullException("command");
18+
19+
_command = command;
20+
_setBindByNameMethod = new Lazy<MethodInfo>(() => InitSetBindByName(_command));
21+
}
22+
23+
private static MethodInfo InitSetBindByName(DbCommand command)
24+
{
25+
return command.GetType().GetMethod("set_BindByName", BindingFlags.Public | BindingFlags.Instance);
26+
}
27+
28+
private MethodInfo SetBindByNameMethod
29+
{
30+
get
31+
{
32+
return _setBindByNameMethod.Value;
33+
}
34+
}
35+
36+
private void SetBindByName()
37+
{
38+
if (_bindByNameIsSet || SetBindByNameMethod == null) return;
39+
40+
SetBindByNameMethod.Invoke(_command, new object[] { true });
41+
_bindByNameIsSet = true;
42+
}
43+
44+
public override void Prepare()
45+
{
46+
_command.Prepare();
47+
}
48+
49+
public override string CommandText
50+
{
51+
get { return _command.CommandText; }
52+
set { _command.CommandText = value; }
53+
}
54+
55+
public override int CommandTimeout
56+
{
57+
get { return _command.CommandTimeout; }
58+
set { _command.CommandTimeout = value; }
59+
}
60+
61+
public override CommandType CommandType
62+
{
63+
get { return _command.CommandType; }
64+
set { _command.CommandType = value; }
65+
}
66+
67+
protected override DbConnection DbConnection
68+
{
69+
get { return _command.Connection; }
70+
set
71+
{
72+
_command.Connection = value;
73+
}
74+
}
75+
76+
protected override DbParameterCollection DbParameterCollection
77+
{
78+
get { return _command.Parameters; }
79+
}
80+
81+
protected override DbTransaction DbTransaction
82+
{
83+
get { return _command.Transaction; }
84+
set { _command.Transaction = value; }
85+
}
86+
87+
public override bool DesignTimeVisible
88+
{
89+
get { return _command.DesignTimeVisible; }
90+
set { _command.DesignTimeVisible = value; }
91+
}
92+
93+
public override UpdateRowSource UpdatedRowSource
94+
{
95+
get { return _command.UpdatedRowSource; }
96+
set { _command.UpdatedRowSource = value; }
97+
}
98+
99+
public override void Cancel()
100+
{
101+
_command.Cancel();
102+
}
103+
104+
protected override DbParameter CreateDbParameter()
105+
{
106+
return _command.CreateParameter();
107+
}
108+
109+
protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior)
110+
{
111+
if (Parameters.Count > 0) SetBindByName();
112+
var reader = _command.ExecuteReader(behavior);
113+
return new OracleDataReader(reader);
114+
}
115+
116+
public override int ExecuteNonQuery()
117+
{
118+
if (Parameters.Count > 0) SetBindByName();
119+
return _command.ExecuteNonQuery();
120+
}
121+
122+
public override object ExecuteScalar()
123+
{
124+
if (Parameters.Count > 0) SetBindByName();
125+
return _command.ExecuteScalar();
126+
}
127+
128+
protected override void Dispose(bool disposing)
129+
{
130+
if (disposing)
131+
{
132+
_command.Dispose();
133+
}
134+
base.Dispose(disposing);
135+
}
136+
}
137+
}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
using System;
2+
using System.Data;
3+
using System.Data.Common;
4+
5+
namespace ServiceStack.OrmLite.Oracle
6+
{
7+
public class OracleConnection : DbConnection
8+
{
9+
private readonly DbConnection _connection;
10+
public OracleConnection(DbConnection connection)
11+
{
12+
if (connection == null)
13+
throw new ArgumentNullException("connection");
14+
15+
_connection = connection;
16+
}
17+
18+
protected override DbTransaction BeginDbTransaction(IsolationLevel isolationLevel)
19+
{
20+
return _connection.BeginTransaction(isolationLevel);
21+
}
22+
23+
public override void Close()
24+
{
25+
_connection.Close();
26+
}
27+
28+
public override void ChangeDatabase(string databaseName)
29+
{
30+
_connection.ChangeDatabase(databaseName);
31+
}
32+
33+
public override void Open()
34+
{
35+
if (_connection.State != ConnectionState.Open)
36+
_connection.Open();
37+
}
38+
39+
public override string ConnectionString
40+
{
41+
get { return _connection.ConnectionString; }
42+
set { _connection.ConnectionString = value; }
43+
}
44+
45+
public override string Database
46+
{
47+
get { return _connection.Database; }
48+
}
49+
50+
public override string DataSource
51+
{
52+
get { return _connection.DataSource; }
53+
}
54+
55+
public override ConnectionState State
56+
{
57+
get { return _connection.State; }
58+
}
59+
60+
public override string ServerVersion
61+
{
62+
get { return _connection.ServerVersion; }
63+
}
64+
65+
protected override DbCommand CreateDbCommand()
66+
{
67+
return new OracleCommand(_connection.CreateCommand());
68+
}
69+
70+
protected override void Dispose(bool disposing)
71+
{
72+
if (disposing)
73+
{
74+
_connection.Dispose();
75+
}
76+
base.Dispose(disposing);
77+
}
78+
}
79+
}

0 commit comments

Comments
 (0)