Skip to content

Bug/Regression doing a query with a jsonb column as string with 2.1.* #2049

Description

@lucax88x

Ciao!

I've reproduced the issue there:

https://github.com/lucax88x/dapper-bug

So, if you have a postgresql db, and you use a jsonb column, and you use netwonsoft as deserializer such as:

NpgsqlConnection.GlobalTypeMapper.UseJsonNet(settings:settings);

and perform a a query like

awaitconn.QueryFirstOrDefaultAsync<string>("select \"Content\" from public.\"Posts\"");

will throw an exception with

---> System.InvalidCastException:Objectmust implement IConvertible.
at System.Convert.ChangeType(Objectvalue,TypeconversionType,IFormatProviderprovider)
at Dapper.SqlMapper.GetValue[T](DbDataReaderreader,TypeeffectiveType,Objectval) in /_/Dapper/SqlMapper.cs:line 1366---End of inner exception stack trace ---atDapper.SqlMapper.ThrowDataException(Exceptionex,Int32index,IDataReaderreader,Objectvalue) in /_/Dapper/SqlMapper.cs:line3928
at Dapper.SqlMapper.QueryRowAsync[T](IDbConnection cnn, Row row, Type effectiveType, CommandDefinition command)in/_/Dapper/SqlMapper.Async.cs:line 496

This happens only with 2.1.*, if I revert to 2.0.151 everything works perfectly.

This is probably the PR that breaks it.

ps: without json.net it also work perfectly, it's just a combination of json.net and jsonb.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions