Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dapper trying to parse wrong column #576

Closed
v0l opened this issue Jul 28, 2016 · 4 comments
Closed

Dapper trying to parse wrong column #576

v0l opened this issue Jul 28, 2016 · 4 comments

Comments

@v0l
Copy link

v0l commented Jul 28, 2016

Run into a small issue with dapper trying to map the previous column to the wrong field in the class and as such is throwing "Specified cast is not valid".

exception

row

   at Dapper.SqlMapper.ThrowDataException(Exception ex, Int32 index, IDataReader reader, Object value)
   at Deserialize04ea767d-0f4a-4b86-ab84-f46ff296e65f(IDataReader )
   at Dapper.SqlMapper.<QueryImpl>d__125`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at Dapper.SqlMapper.Query[T](IDbConnection cnn, String sql, Object param, IDbTransaction transaction, Boolean buffered, Nullable`1 commandTimeout, Nullable`1 commandType)

Inner exception

     at Oracle.ManagedDataAccess.Client.OracleDataReader.GetDecimal(Int32 i)
   at Oracle.ManagedDataAccess.Client.OracleDataReader.GetValue(Int32 i)
   at Oracle.ManagedDataAccess.Client.OracleDataReader.get_Item(Int32 i)
   at Deserialize04ea767d-0f4a-4b86-ab84-f46ff296e65f(IDataReader )

Nuget package version s

<package id="Oracle.ManagedDataAccess" version="12.1.24160419" targetFramework="net45" />
<package id="Dapper" version="1.50.2" targetFramework="net45" />
@v0l
Copy link
Author

v0l commented Jul 28, 2016

After some digging this appears to be an issue with OracleDataReader.

Its attempting to parse NUMBER as decimal but the max precision is 28-29?

This error message with "PRICE=L" is just an incorrect error. It was attempting to parse the correct column.

create table test2 ( test NUMBER );
insert into test2 values(0.36363636363636363636363636363636363636);
commit;
--Try the select * from test2; this will fail

update test2 set test = 0.3636363636363636363636363636;
commit;
--this one will work fine

@NickCraver
Copy link
Member

Since this is really an Oracle problem, I'm not sure there's anything we can do about the root exception here, unfortunately. If the error message is off in the current version, that certainly needs a fix though.

@NickCraver
Copy link
Member

Any update here?

@cottsak
Copy link

cottsak commented Feb 1, 2017

I think this is rather Microsoft's implementation that's at fault: always trying to cast to a Decimal, when sometimes that won't work.

I'm going to try and truncate the value in the Oracle query before it gets to the Oracle.ManagedDataAccess package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants