Dapper fails on MySql nullable bool #552

Closed
RobRolls opened this Issue Jul 8, 2016 · 21 comments

Comments

Projects
None yet
8 participants
@RobRolls

RobRolls commented Jul 8, 2016

Dapper is throwing an error when I try to use a nullable bool with MySql.

Error parsing column 1 (IsBold=0 - SByte)

It only breaks when a statement follows the null value insert statement.

An additional note, it works fine if I manually change the size of IsBold from tinyint(1) (the default created by BOOLEAN) to 2 or greater.

        [Fact]
        public void TestSuccess()
        {
            using (var conn = GetMySqlConnection(true, true, true))
            {
                try { conn.Execute("drop table boolTest_Test"); } catch { }
                conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
                conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");
                conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");

                var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

                Assert.True(rows[1].IsBold);
                Assert.Null(rows[2].IsBold);
            }
        }

        [Fact]
        public void TestFail()
        {
            using (var conn = GetMySqlConnection(true, true, true))
            {
                try { conn.Execute("drop table boolTest_Test"); } catch { }
                conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
                conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");
                conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");

                var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

                Assert.True(rows[1].IsBold);
                Assert.Null(rows[2].IsBold);
            }
        }

        class BoolTest
        {
            public int Id { get; set; }
            public bool? IsBold { get; set; }
        }
@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 8, 2016

Contributor

OK; I will have a look this morning and see if I can spot the problem. It
seems especially odd that this seems to be dependent on row order, but ...
well, I'll see what I can find :)
On 8 Jul 2016 1:22 a.m., "RobRolls" notifications@github.com wrote:

Dapper is throwing an error when I try to use a nullable bool with MySql.

Error parsing column 1 (IsBold=0 - SByte)

It only breaks when a statement follows the null value insert statement.

An additional note, it works fine if I manually change the size of IsBold
from tinyint(1) (the default created by BOOLEAN) to 2 or greater.

    [Fact]
    public void TestSuccess()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    [Fact]
    public void TestFail()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    class BoolTest
    {
        public int Id { get; set; }
        public bool? IsBold { get; set; }
    }


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#552, or mute the
thread
https://github.com/notifications/unsubscribe/AABDsNptrcnHUUi41tFNMeW8V5Pmau0Kks5qTZhJgaJpZM4JHn0N
.

Contributor

mgravell commented Jul 8, 2016

OK; I will have a look this morning and see if I can spot the problem. It
seems especially odd that this seems to be dependent on row order, but ...
well, I'll see what I can find :)
On 8 Jul 2016 1:22 a.m., "RobRolls" notifications@github.com wrote:

Dapper is throwing an error when I try to use a nullable bool with MySql.

Error parsing column 1 (IsBold=0 - SByte)

It only breaks when a statement follows the null value insert statement.

An additional note, it works fine if I manually change the size of IsBold
from tinyint(1) (the default created by BOOLEAN) to 2 or greater.

    [Fact]
    public void TestSuccess()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    [Fact]
    public void TestFail()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    class BoolTest
    {
        public int Id { get; set; }
        public bool? IsBold { get; set; }
    }


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#552, or mute the
thread
https://github.com/notifications/unsubscribe/AABDsNptrcnHUUi41tFNMeW8V5Pmau0Kks5qTZhJgaJpZM4JHn0N
.

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 8, 2016

Contributor

It looks like it should work fine. I can look, but I will need to install
some extra pieces first. Have you tried with the most recent version of
dapper (with pre-release enabled)?

Install-Package Dapper -Pre

Marc
On 8 Jul 2016 7:46 a.m., "Marc Gravell" marc.gravell@gmail.com wrote:

OK; I will have a look this morning and see if I can spot the problem. It
seems especially odd that this seems to be dependent on row order, but ...
well, I'll see what I can find :)
On 8 Jul 2016 1:22 a.m., "RobRolls" notifications@github.com wrote:

Dapper is throwing an error when I try to use a nullable bool with MySql.

Error parsing column 1 (IsBold=0 - SByte)

It only breaks when a statement follows the null value insert statement.

An additional note, it works fine if I manually change the size of IsBold
from tinyint(1) (the default created by BOOLEAN) to 2 or greater.

    [Fact]
    public void TestSuccess()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    [Fact]
    public void TestFail()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    class BoolTest
    {
        public int Id { get; set; }
        public bool? IsBold { get; set; }
    }


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#552, or mute
the thread
https://github.com/notifications/unsubscribe/AABDsNptrcnHUUi41tFNMeW8V5Pmau0Kks5qTZhJgaJpZM4JHn0N
.

Contributor

mgravell commented Jul 8, 2016

It looks like it should work fine. I can look, but I will need to install
some extra pieces first. Have you tried with the most recent version of
dapper (with pre-release enabled)?

Install-Package Dapper -Pre

Marc
On 8 Jul 2016 7:46 a.m., "Marc Gravell" marc.gravell@gmail.com wrote:

OK; I will have a look this morning and see if I can spot the problem. It
seems especially odd that this seems to be dependent on row order, but ...
well, I'll see what I can find :)
On 8 Jul 2016 1:22 a.m., "RobRolls" notifications@github.com wrote:

Dapper is throwing an error when I try to use a nullable bool with MySql.

Error parsing column 1 (IsBold=0 - SByte)

It only breaks when a statement follows the null value insert statement.

An additional note, it works fine if I manually change the size of IsBold
from tinyint(1) (the default created by BOOLEAN) to 2 or greater.

    [Fact]
    public void TestSuccess()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    [Fact]
    public void TestFail()
    {
        using (var conn = GetMySqlConnection(true, true, true))
        {
            try { conn.Execute("drop table boolTest_Test"); } catch { }
            conn.Execute("create table boolTest_Test (Id int not null, IsBold BOOLEAN null );");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (2,null);");
            conn.Execute("insert boolTest_Test (Id, IsBold) values (1,1);");

            var rows = conn.Query<BoolTest>("select * from boolTest_Test").ToDictionary(x => x.Id);

            Assert.True(rows[1].IsBold);
            Assert.Null(rows[2].IsBold);
        }
    }

    class BoolTest
    {
        public int Id { get; set; }
        public bool? IsBold { get; set; }
    }


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
#552, or mute
the thread
https://github.com/notifications/unsubscribe/AABDsNptrcnHUUi41tFNMeW8V5Pmau0Kks5qTZhJgaJpZM4JHn0N
.

@RobRolls

This comment has been minimized.

Show comment
Hide comment
@RobRolls

RobRolls Jul 8, 2016

Marc,

I agree, this stuck me as odd as well. I have tried it with the most current version. Currently have dapper.1.50.0-rc3 installed.

I can provide a stripped down solution if it helps.

Thanks for your help!

RobRolls commented Jul 8, 2016

Marc,

I agree, this stuck me as odd as well. I have tried it with the most current version. Currently have dapper.1.50.0-rc3 installed.

I can provide a stripped down solution if it helps.

Thanks for your help!

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 8, 2016

Contributor

The example you have should be fine; my blocker is simply that I've just
flattened all my OSes (to get a clean VS install), and don't have mysql
yet. SQL Server doesn't have this data type. Will look.

On Fri, 8 Jul 2016 09:06 RobRolls, notifications@github.com wrote:

Marc,

I agree, this stuck me as odd as well. I have tried it with the most
current version. Currently have dapper.1.50.0-rc3 installed.

I can provide a stripped down solution if it helps.

Thanks for your help!


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#552 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AABDsEFomsbwfWkSF_BkwTV-ol0giRCnks5qTgTygaJpZM4JHn0N
.

Contributor

mgravell commented Jul 8, 2016

The example you have should be fine; my blocker is simply that I've just
flattened all my OSes (to get a clean VS install), and don't have mysql
yet. SQL Server doesn't have this data type. Will look.

On Fri, 8 Jul 2016 09:06 RobRolls, notifications@github.com wrote:

Marc,

I agree, this stuck me as odd as well. I have tried it with the most
current version. Currently have dapper.1.50.0-rc3 installed.

I can provide a stripped down solution if it helps.

Thanks for your help!


You are receiving this because you commented.

Reply to this email directly, view it on GitHub
#552 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AABDsEFomsbwfWkSF_BkwTV-ol0giRCnks5qTgTygaJpZM4JHn0N
.

@bastiflew

This comment has been minimized.

Show comment
Hide comment
@bastiflew

bastiflew Jul 20, 2016

Hi,

I have exactly the same issue, but I use byte? instead of bool.
I have a lot a row with null in this column, and when the first line with 0 comes, Dapper throw the same Exception.
I put 0 in every row, and there is no exception.
It seems that the problem happens when the previous row is null.

Thanks

Hi,

I have exactly the same issue, but I use byte? instead of bool.
I have a lot a row with null in this column, and when the first line with 0 comes, Dapper throw the same Exception.
I put 0 in every row, and there is no exception.
It seems that the problem happens when the previous row is null.

Thanks

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 20, 2016

Contributor

@bastiflew can you confirm the exact error message when it happens to you? In particular, the bit in brackets

Contributor

mgravell commented Jul 20, 2016

@bastiflew can you confirm the exact error message when it happens to you? In particular, the bit in brackets

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 20, 2016

Contributor

(the good news is that I have MySQL up and running on my new OS build, so I can actually investigate this now)

Contributor

mgravell commented Jul 20, 2016

(the good news is that I have MySQL up and running on my new OS build, so I can actually investigate this now)

@bastiflew

This comment has been minimized.

Show comment
Hide comment
@bastiflew

bastiflew Jul 20, 2016

@mgravell the message : "Error parsing column 10 (svc_desynchro=0 - SByte)"}

@mgravell the message : "Error parsing column 10 (svc_desynchro=0 - SByte)"}

mgravell added a commit that referenced this issue Jul 20, 2016

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 20, 2016

Contributor

Well shoot, the problem here is that MySQL lies initially, and changes its mind about the schema in the middle of iterating it. I cannot stress just how horribly broken this is - an epic bug in the mysql data provider. It is not meant to do this. I'll have to see whether dapper can work around it somehow. But to illustrate with what the reader reports 1) initially, 2) after the first row (null), and 3) after the second row (non-null):

> reader.GetFieldType(0).FullName + " | " + reader.GetFieldType(1).FullName
"System.Int32 | System.Boolean"
> reader.Read()
true
> reader.GetFieldType(0).FullName + " | " + reader.GetFieldType(1).FullName
"System.Int32 | System.Boolean"
> reader[0] + " | " + reader[1]
"1 | "
> reader.Read()
true
> reader.GetFieldType(0).FullName + " | " + reader.GetFieldType(1).FullName
"System.Int32 | System.SByte"
> reader[0] + " | " + reader[1]
"2 | 0"

The thing to call out there is where the schema changes from "System.Int32 | System.Boolean" to "System.Int32 | System.SByte". If it had reported SByte initially, dapper would have used an alternative code branch (specifically, FlexibleConvertBoxedFromHeadOfStack instead of a simple OpCodes.Unbox_Any). The problem is that the decisions dapper makes at IL emit time are based on the BOF schema, i.e. before Read() has been called.

Contributor

mgravell commented Jul 20, 2016

Well shoot, the problem here is that MySQL lies initially, and changes its mind about the schema in the middle of iterating it. I cannot stress just how horribly broken this is - an epic bug in the mysql data provider. It is not meant to do this. I'll have to see whether dapper can work around it somehow. But to illustrate with what the reader reports 1) initially, 2) after the first row (null), and 3) after the second row (non-null):

> reader.GetFieldType(0).FullName + " | " + reader.GetFieldType(1).FullName
"System.Int32 | System.Boolean"
> reader.Read()
true
> reader.GetFieldType(0).FullName + " | " + reader.GetFieldType(1).FullName
"System.Int32 | System.Boolean"
> reader[0] + " | " + reader[1]
"1 | "
> reader.Read()
true
> reader.GetFieldType(0).FullName + " | " + reader.GetFieldType(1).FullName
"System.Int32 | System.SByte"
> reader[0] + " | " + reader[1]
"2 | 0"

The thing to call out there is where the schema changes from "System.Int32 | System.Boolean" to "System.Int32 | System.SByte". If it had reported SByte initially, dapper would have used an alternative code branch (specifically, FlexibleConvertBoxedFromHeadOfStack instead of a simple OpCodes.Unbox_Any). The problem is that the decisions dapper makes at IL emit time are based on the BOF schema, i.e. before Read() has been called.

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 20, 2016

Contributor

I've had a suggestion (from someone else equally frustrated by the mysql connector) to try using the mysql connector of devart instead; apparently it is far less broken! I cannot vouch for this myself, as I am not a mysql user (except for debugging things): https://www.devart.com/dotconnect/mysql/

Contributor

mgravell commented Jul 20, 2016

I've had a suggestion (from someone else equally frustrated by the mysql connector) to try using the mysql connector of devart instead; apparently it is far less broken! I cannot vouch for this myself, as I am not a mysql user (except for debugging things): https://www.devart.com/dotconnect/mysql/

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 20, 2016

Contributor

I've logged this as a bug against the mysql connector: http://bugs.mysql.com/bug.php?id=82292

Contributor

mgravell commented Jul 20, 2016

I've logged this as a bug against the mysql connector: http://bugs.mysql.com/bug.php?id=82292

@rykr

This comment has been minimized.

Show comment
Hide comment
@rykr

rykr Jul 20, 2016

I've forwarded this to the correct person. We'll look at this right away. This should be happening.

rykr commented Jul 20, 2016

I've forwarded this to the correct person. We'll look at this right away. This should be happening.

@bastiflew

This comment has been minimized.

Show comment
Hide comment
@bastiflew

bastiflew Jul 20, 2016

Thanks for your efforts. I will change from MySQL .NET to DevArt Express until this issue is fixed.

Thanks for your efforts. I will change from MySQL .NET to DevArt Express until this issue is fixed.

bgrainger added a commit to mysql-net/MySqlConnector that referenced this issue Jul 20, 2016

Verify that nullable bools are handled correctly.
Adapted from a bug reported against the official connector at StackExchange/Dapper#552.
@bgrainger

This comment has been minimized.

Show comment
Hide comment
@bgrainger

bgrainger Jul 20, 2016

Contributor

Shameless plug: You can also avoid this error by switching to https://github.com/mysql-net/MySqlConnector. When I was developing its code, I ran across MySQL bug 78917 which seems to be the same underlying issue. (But just to be sure, I added a new test to verify the behaviour doesn't repro.)

Contributor

bgrainger commented Jul 20, 2016

Shameless plug: You can also avoid this error by switching to https://github.com/mysql-net/MySqlConnector. When I was developing its code, I ran across MySQL bug 78917 which seems to be the same underlying issue. (But just to be sure, I added a new test to verify the behaviour doesn't repro.)

@mgravell

This comment has been minimized.

Show comment
Hide comment
@mgravell

mgravell Jul 20, 2016

Contributor

@bgrainger thanks; fully agree that this is a duplicate of 78917 - good catch. Will update on my bug. The existing one deserves to be primary.

Contributor

mgravell commented Jul 20, 2016

@bgrainger thanks; fully agree that this is a duplicate of 78917 - good catch. Will update on my bug. The existing one deserves to be primary.

@xavierpena

This comment has been minimized.

Show comment
Hide comment
@xavierpena

xavierpena Sep 6, 2016

@mgravell I understand that the error is coming from the MySQL connector, but are there any news regarding this error? Any workaround whatsoever?

I have tried this StackOverflow solution (changing from bool? to Byte?, which is the tinyint equivalent in c#) but it hasn't worked for me.

I tried @bgrainger solution, but I had problems using it (see issue here), plus it lacked the Compress=True; parameter compatibility, so I made a rollback.

Edit: added MySqlConnector issue link

xavierpena commented Sep 6, 2016

@mgravell I understand that the error is coming from the MySQL connector, but are there any news regarding this error? Any workaround whatsoever?

I have tried this StackOverflow solution (changing from bool? to Byte?, which is the tinyint equivalent in c#) but it hasn't worked for me.

I tried @bgrainger solution, but I had problems using it (see issue here), plus it lacked the Compress=True; parameter compatibility, so I made a rollback.

Edit: added MySqlConnector issue link

@344303947

This comment has been minimized.

Show comment
Hide comment
@344303947

344303947 Nov 10, 2017

connectionString :Treat Tiny As Boolean=false;

connectionString :Treat Tiny As Boolean=false;

@bgrainger

This comment has been minimized.

Show comment
Hide comment
@bgrainger

bgrainger Nov 10, 2017

Contributor

Treat Tiny As Boolean=false

I would advise against this, because now any BOOL columns created in MySQL will get returned to .NET as byte values (then you must perform a != 0 check if you want an actual bool).

Instead, my advice remains to switch to https://github.com/mysql-net/MySqlConnector (NuGet).

Contributor

bgrainger commented Nov 10, 2017

Treat Tiny As Boolean=false

I would advise against this, because now any BOOL columns created in MySQL will get returned to .NET as byte values (then you must perform a != 0 check if you want an actual bool).

Instead, my advice remains to switch to https://github.com/mysql-net/MySqlConnector (NuGet).

@xavierpena

This comment has been minimized.

Show comment
Hide comment
@xavierpena

xavierpena Nov 11, 2017

@bgrainger I can confirm. I've been using MySqlConnector since I had the problem, and it works like a charm.

In the beginning I was wary because of Compress=True; not working in that particular connector, but I've been using it in multiple projects and overall the experience has been great.

@bgrainger I can confirm. I've been using MySqlConnector since I had the problem, and it works like a charm.

In the beginning I was wary because of Compress=True; not working in that particular connector, but I've been using it in multiple projects and overall the experience has been great.

joangilabert added a commit to joangilabert/dapper-dot-net that referenced this issue Apr 16, 2018

actualizacion desde el original (#1)
* Tests: add 4 attempts to repro #457

* Change CE package to one that might work

* Fix *all* the CE references

* Don't attempt to load native assemblies on DNX

* Detect app-veyor for MySql/Postgresql

* Standardize on test db for appveyor

* actual/expected in asserts are the wrong way round

All the tests are wrote in the form actual.IsEqualTo(expected). This
made for some odd error messages when a test failed.

* Initial test setup for #461; note that this does not repro, due to running on SQL-Server - needs to be changed to SQLite to repro

* Fix #461 - change FindConstructor to allow parameters that have a type-handler defined

* New feature: PadListExpansions - reduces query plan saturation by padding "in" lists and populating with nulls; opt-in (see remarks on setting)

* 1.50-beta8 deploy

* Fix typos in the comments for PadListExpansions

* Test for SO35470588

* Readme.md: update performance tests link

* Example for SO35554284

* Add SQLITE to test builds; add tests for issues #466 and #467; fix #466 by adding retry-with-fallback flags strategy

* Update to sqlite rc2, because without that nothing works; add extra tests around sqlite oddities; update tests to reflect sqlite rc2 fixes

* Fix #468 - CreateParamInfoGenerator should treat enums as primitives, not box them as enums

* Don't check for null in the basic enum case

* Support get-only C# 6 properties, i.e. `public int Id {get;}`

* prefer an exact-case backing-field match over a wrong-case regular field (essentially: this promotes get-only properties over regular fields)

* Support xml types by default (XmlDocument, XDocument, XElement) - fix #427

* Set the DbType for XmlDocument / XDocument / XElement

* When doing list expansions (6=>10 etc), use the last non-trivial value - do *NOT* use null, as it causes problems with "not in" clauses; add test for the same

* Recreate all the xproj to reflect the current tooling - old versions break VS15; enable XDocument etc in corefx (#if block was too large)

* Heh, AspNet and DNX (only) work in VS2015; DNX and DotNet (only) work in VS15; I guess we need to use DNX for now, then, as the only one that works in both.

* 1.50-beta9

* Unify test credentials for MySQL; add passing test for SO36303462

* Bumping dependencies version numbers

* Revert "Bumping dependencies version numbers"

This reverts commit 70ee9a7.

* Readme: Better explanation for multi mapping

* fix outpt paths

* Get building

* PowerShell build scripts

* PowerShell build updates: include .Contrib

* PowerShell build script love

* Add bash build scripts

Note: these are hosed on OS X due to file handle limits, see
dotnet/cli#809 for details.

* Bash build: fix test runner on OS X

Note: no tests pass because there’s no integrated security option (or
widely available SQL server) on OS X at the moment. But the build and
test runners are up and going.

* Update .gitgnore for build pathing

* .Net Core: remove floating versions (use stable ones on Nuget.org) and get this puppy back in action.

Also: it's 2016.

* Add newer feed back **only for the tests projects**, Sqlite for example has bugs in rc1-final fixed in rc2-15948

* Nuget.org feed only, skip the 2 Sqlite tests until RC2+ packages with the fix are out of pre-release.

* Fix assembly name for Contrib tests

* Runtimes fix, per dotnet/cli#2578

* Fix EntityFramework.StrongName build for RC2

* Update to RC2 final build (24027) libraries. Also bump to beta10

* RC2: Remove CoreFX #1612 blocker - fix is released, yay!

dotnet/corefx#1612 is now closed, tests
working.

* Upgrade project.json files to RC2 format.

Note: on a nuspec comparison, the following dependencies aren't there
anymore: Microsoft.CSharp, mscorlib, System, and System.Core aren't
explicitly specified in frameworkAssemblies anymore. The only one of
these I can imagine mattering is Microsoft.CSharp.

* It's time for appveyor.yml

Tooling changes need to live in the repo now so the build doesn't FUBAR
every time we change the script.

* It took several people a while to find this one.

* RC2 Version bump, since we locked ourselves in with semver on beta9

* Update build scripts to pack for us

* JSON RC2 fixes

* Interfaces are back, simplifying code.

Related issue: #520

* net451 test prep (not quite ready - SQL Geo and interop failing)

* XMLDoc fixes for latest methods and missing DataSet in .NET Core

* .xproj: RC2 upgrade

This fixes null refs with the DNX MSBuild targets when building from
Visual Studio.

* Switch version suffix to be a build parameter

Note: build.sh needs love from OS X/*nix later to match

* This .0 addition happens automatically...make it explicit instead.

* git blame game

* Test for #524 (believed to be a failing test; cannot validate or Fix until I get the latest tooling installed)

* Fix #524 - `GridReader` should use the same conversion code as the regular reader

* Add InListStringSplitCount; when set, causes `in @foo` parameters to be implemented using string_split

* fix case of generated SQL in string-split

* Dapper.EF.StrongName: should snk for *all* builds!

* Fixed some syntax errors in project.json files.

* .Net Core 1.0 RTM update

* Remove a bunch of unnecessary (and *theoretically* dangerous, in a very unlikely scenario involving custom cultures installed on a box) C# 7 string $"...{...}..." usages

* Simplify the string_split implementation

* 1.50.1 deploy

* Rename DataTable=>DapperTable; fix #549

* Failing test for #552

* (just to prove that #552 still happens even if the only values seen are 0 and 1)

* Fix for #569

* 1.50.2

* Repackage Dapper.EF to fix System.Runtime; deploy as .52; fix xunit refs; add test for #570

* Added tests to complement documentation of pseudo-positional parameters

* Fix SqlBuilder.OrWhere method which was actually yielding an 'AND WHERE' statement.

* Operate on db records instead of files.

* Add CommannDefinition versions of Query(First,FirstOrDefault,Single,SingleOrDefault)Async and a few unit tests for them

* Improve tests

* failing test for #563

* fix broken test to actually include the error!

* Make CommandBehavior more configurable; default to SingleRow=allowed,SingleResult=disallowed - but expose options; this fixes issues like #563 automatically, and allows the performance aspect  of #554 to be fixed via a global setting

* support for international parameter names (regex categories); fix #601

* Add some <remarks> to the new options

* Capitalization

* Update readme.md

Missed second bracket in ID example

* Set true to GridReader.IsConsumed when MultiReadInternal is called

* Non-greedy match for comments regex

Fixes #436, #280
My editor has also normalized a few line endings to LF like 99% of the
file was.

* Fix #634 - dapper now handles connection lifetime and has for ages

* 1.50.3-beta1: looks at #637  re `Guid`

* Toolng cheese move - lock in preview2 for now.

* Fix Contrib test resolution

Note: there's still a 1.0.0 vs 1.1.0 quirk here - digging.

* Add SqlMapper.RemoveTypeMap() method

* Update Readme.md

* Add test DiscriminatedUnionWithMultiMapping

DiscriminatedUnionWithMultiMapping - test for check correct MultiMapping (splitOn) functionality with discriminated row parser.

* added firebird support

added firebird sql adapter to allow record insert and key retrieving

* Revert "1.50.3-beta1: looks at #637  re `Guid`"

This reverts commit 91725fb.

* Update README with documentation for [ExplicitKey] attribute

* Add GetRowParser documentation/example

* Fix missing Firebase Async, issue #695

TODO: All of these need race love in V2, complete re-vamp.

* Rename package to "Dapper"

Related: #683

* Remove note about requiring open connections

* Added Belgrade Sql Client

In the performance benchmark is added Belgrade Sql client data access
library (https://github.com/JocaPC/CLR-Belgrade-SqlClient). This is a
wrapper around ADO.NET classes that executes queries in async manner
using callbacks. "Belgrade.Sql.Client": "0.6.2" is aded in project.json
file, and new flag "BELGRADE" controls should the test be executed.

* migrate release notes to [master]/docs

* Set theme jekyll-theme-cayman

* Add a full stop just so I can tell if the docs migration is working

* Fix Dapper release notes link

* Security!

* Fixed test issue in Simple.Data performance test (#723)

* Added fix for Simple.Data tast

Due to the missing .FirstOrDefault() in Simple.Data test, performance
numbers for Simple.Data were too high (better than hand coded data
reader). Added FirstOrDefault() to actually fetch the data.

* VS 2017 .csproj Migration
Due to the way VS test works (by injecting an executable entry point), the performance tests needed to be factored out. I also organized all of our existing tests better along the way.
Actual code changes to Dapper itself are very minor, only formatting and documentation fixes (which we need many more of).

The build.ps1 script is upated to work, but note that <frameworkAssemblies> is not working in .nuspec inside the packages in the new .csproj system. I consider this to be a blocker. Issue is here: NuGet/Home#4853

* Correct minor typographical error in Readme.md (#732)

Under the `List Support` section, the sentence opens with `Dapper allow you`, which should instead be `Dapper allows you`. This PR will correct this mistake, restoring balance to the universe.

After originally spotting this, the most minor of mistakes, I decided to leave it and move on with my life, since it likely effected nobody. Four hours passed and the thought that it existed unchecked had fully manifested itself within my subconscious and I was no longer able to continue with my existence knowing that I had seen this mistake and not exercised my power to correct it.

Thank you, and sorry.

* Define expected behaviour for value-tuple parameters and returns, and implement

* remove redundant test code (oops)

* Better matching of value-tuple names when wrong number of columns - should return nulls for unmapped

* Add tests for the too few/too many columns scenarios for value-tuples; happy to discuss alternative expectations

* Fix Readme typos (#739)

* Readme.md: Fixed link to test suite (#764)

* VS 2017 Build - Making things work (#766)

* Progress on VS 2017 build tooling
* Finally, a working VS 2017 tooling build

* Update appveyor.yml for 2017 build

* Appveyor: update services

* Let's try this again

* Again!

* More path changes

* Appveyor: SQL 2016

* Appveyor: create databases

* Let's just keep adding YAML until this works.

* Appveyor: Formatting & combine init

* Appveyor: Update Postgres path

* Lots of documentation fixes/additions.

* Fix Microsoft.SqlServer.Types for new .csproj

* Fix type loads for the builds without SQL in the GAC

* Fix SQL spatial type loading

* Skip the MySQL FUBAR test

It's indeed broken on their end. We should consider switching providers,
e.g. https://github.com/mysql-net/MySqlConnector/

* Add build badge to README

* Appveyor: enable MyGet publishing

* Lots of code cleanup, no functional changes

* C# 7 cleanup: pattern matching for TryStringSplit

* Documentation: GridReader

* Documentation: contrib

* Documentation: EntityFramework

* Documentation: Rainbow

* Tests: make analyzers happy because why not

* Documentation and formatting: secondary types

* Documentation and formatting: SqlMapper

* Benchmarks v2: BenchmarkDotNet and friends

This is based on BenchmarkDotNet (while preserving the legacy format
with minor improvements as well - legacy runs much faster). See #666 for
details. Not an ominus number at all.

Note: this code will get a bit simpler with BenchmarkDotNet categories,
see dotnet/BenchmarkDotNet#248 for details.

* Dependency: Dapper doesn't need SqlClient, only Data.Common

* Benchmarks: customization and formatting

More cleanup to do (removing Type column next), but getting to some very
usable output now.

* netstandard2.0 functionality (w/ runtime breaks)

This adds a netstandard2.0 build to Dapper (and StrongName until v2),
adds a netstandard2.0 test lineup, restores most functionality (except
UDTs for SQL, e.g. .UdtTypeName isn't in netstandard2), and also breaks
things not actually implemented or implemented correctly in
netstandard2.0. Pushing this up so we can work through these with the
.NET teams.

Several things are still broken here (and fail tests):
- Parameter decimal values (not filed yet)
- DataTables as parameters
(dotnet/corefx#19708)
- .GetSchemaTable() (not yet filed, implementation is completely missing
from SqlDataReader in CoreFX)

While the compile is clean, the above are runtime issues.
`SqlParameter.UdtTypeName` is a separate issue, that one just wasn't in
`netstandard2.0` at all...so we can't support UDTs there until it is.
See dotnet/corefx#17126 for details.

* Fix MySQL tests and disposal (#774)

* Don't create the connection in Dispose: this avoids creating a SQLConnection simply to Dispose it.
* Run MySQL tests against the open MySqlConnection: 'connection' is a protected variable in the TestBase class that is a SQL Server connection, not a MySQL connection.
* Skip broken MySQL tests: as per issue #295, setting "AllowZeroDateTime=True" in the connection string causes an InvalidCastException in SqlMapper.

* Benchmarks: performance and formatting

* Minor README tweaks. (#776)

Use an HTTPS link where possible.
Fix 404 for performance tests.

* Fix for InsertAsync in PostgresAdapter (#689)

* Fix for PostgresAdapter in SqlMapperExtensions.Async. Copied same line of code from SqlMapperExtensions to fix RuntimeBinderException on InsertAsync
* Cleanup

* Try and use BenchmarkDotNet correctly

OperationsPerInvoke is an informational, not instructional property.
What we actually want is the UnrollFactor. Moved into the job definition
to simplify things.

* fix issue #731: AddDynamicParameters repeated if paramtype is DbStiring should work.

* Added EntityFrameworkCore performance tests (#778)

* Perf: add EntityFramework Core to legacy tests

* Markdown tables (#800)

Markdown tables instead of html
“Can be faster” in correct row

* Enable SqlDataRecord TVPs on corefx. (#801)

* Revert "Enable SqlDataRecord TVPs on corefx. (#801)" (#803)

This reverts commit e7ad087.

* Appveyor: use the VS 2017 preview image

* Avoid allocation for linq in CreateParamInfoGenerator and added some other micro optimizations

* Enable SqlDataRecord TVPs on netstandard1.3. (#802)

* Enable SqlDataRecord TVPs on netstandard1.3.
* Update netstandard2.0 SqlClient references to Preview 2.
* Skip TransactionScope tests for netcoreapp2.0.
- According to dotnet/corefx#12534, ambient transaction enlistment is not included with .net core 2.0.
* Update references in Dapper.StrongName.
* Disable parallel test run to stabilize flaky type handler tests.
* Disable parallel test run by assembly attribute.
* Move Issue461 tests to TypeHandlerTests.
* Group type handler tests in a collection, re-enable parallelization.
- Being part of the same collection, type handler tests will run sequentially. All other tests can run in parallel.
* Move tests relying on query cache & type maps to a separate collection.

* Upgade libs, fix tests

This uses the new non-parallel-at-the-end I added to xUnit in xunit/xunit#1411 This way we can run any global test that are other-test-unfriendly much more easily.

* More test fixes

* Appveypr: update to base 2017 image again

.NET Core 2 SDK is on the base Appveyor image now

* Update semver, add to solution

* Fix for #808

Add dynamic overloads for:
- QueryFirstAsync
- QueryFirstOrDefaultAsync
- QuerySingleAsync
- QuerySingleOrDefaultAsync

This may change a lot in 2.x, but many people asking for them now so here they are. Unit tests also fixed for QuerySingleOrDefaultAsync.

Note: this builds on the netstandard2 branch because of the xUnit changes to go with VS 2017 15.3.

* Fix for #815

New overload so this isn't a breaking change. We can collapse down in v2.0 (including the Impl method).

* Update README to remove advetisements

* Tests: xUnit cleanup

This change:
- Removes the Assert shim
- Uses recommended xUnit methods (improving fail errors)
- Cleans up exception tests
- General test formatting fixes
- Removes the netcoerapp1.0 only testing (oops commit)

* Cleanup

* Fix unit tests

* Update README for new assertions

* net40 is dead - remove #if ASYNC bits

* .editorconfig and formatting

* Misc build analyzer fixups

* Lib updates and prep for netstandard2.0 alpha

* Dapper.Contrib: netstandard2.0

* Fix build script

Removes NuGet workaround for pre-2.0 and lines up with other script
enhancements since.

* MyGet feed!

Adding a dapper specific feed, for much easier pushing to NuGet. When
they implement Ctrl+Click in the UI this won't be necessary...or we
break down and automate it finally. Depends on signing plans later.

* Add literal replacement example to readme

* Additional notes on literal replacements

* words are hard

* Tests for DateTime2 compatibility

This shows the importance of using DbType.DateTime2 in Dynamic Parameters to avoid precision truncation

* Shortened the changes

Combined 2 tests into one

* when inserting, check if type implements IEnumerable<T> to determine if it's a collection (#880)

* when inserting check if type implements IEnumerable<T> to determine if it's a collection
* when inserting, check if type is a collection by comparing its implemented interfaces to unbound generic type IEnumerable<> instead of the name "IEnumerable`1"

* bump semver for next release

* Ignore .vscode/

* 1.50.4 release

* Bump semver for next release to 1.50.5-alpha*

* Fix benchmark description typos (#932)

* fix equal tests (#944)

* fix equal tests

* fix test

* Test and fix for #591

This brings behavior QueryAsync behavior on par with Query (sync) and properly returns nothing when an empty result set is encountered.

* Code formatting fix (tabs to spaces) (#896)

* Make DapperRow implement IReadOnlyDictionary<string, object> (#913)

* Change to GetAll to allow the usage of a nullable type in T when T is an interface… #933 (#936)

* Change to GetAll to allow the usage of a nullable type in T when T is an interface.

* Change to GetAll to allow the usage of a nullable type in T when T is an interface: further change to check if val == null and if so then don't try to assign it as a property value.

* Change to Get to allow the usage of a nullable type in T when T is an interface. (effectively the same change as the previous change to GetAll.)

* Change to GetAsync and GetAllAsync to allow the usage of a nullable type in T when T is  an interface.

* Added in UserWithNullableDob and IUserWithNullableDob.

Added in tests for GetAndGetAllWithNullableValues and  GetAsyncAndGetAllAsyncWithNullableValues.

* Added in .ConfigureAwait(false) in the GetAsync Test.
Added comment to identify which issue the test relates to.

* Added NullableDates tables to the test databases.
Adjusted variable names in GetAndGetAllWithNullableValues and GetAsyncAndGetAllAsyncWithNullableValues.

* Changed IUserWithNullableDob to INullableDate.

* fix Insert<T> when T is declared as IEnumerable<T> (#948)

* Removing unjustified use of AppendFormat in StringBuilder class (#989)

* Remove reference to Stack Overflow docs 

Should resolve #992

* Better error messages for .*Async methods when not using  DbConnection (#986)

* Better error messages for .*Async methods when not using  DbConnection

Perhaps in v2 we move these to DbConnection itself ratherr than IDbConnection for the extensions to eliminate the case, but that's breaking...for now we can at least throw a better error. See #757 for details.

* Tweak errors to allow open IDbConnections and those generating DbCommands

Same checks but a bit more lenient with more specific messaging.

* Tweaking error messages and supporting IDbConnection implementations … (#987)

* Fixed dead link in Readme.md

Replaced a dead link in Readme.md by a link to the WaybackMachine

* Readme.md misc tidying
@NickCraver

This comment has been minimized.

Show comment
Hide comment
@NickCraver

NickCraver May 20, 2018

Member

Closing this out since it's a provider issue, and changing providers resolves it.

Member

NickCraver commented May 20, 2018

Closing this out since it's a provider issue, and changing providers resolves it.

@NickCraver NickCraver closed this May 20, 2018

@bgrainger

This comment has been minimized.

Show comment
Hide comment
@bgrainger

bgrainger Jun 2, 2018

Contributor

For anyone affected by this who wants to stick with MySql.Data, they just announced that this will be fixed in 6.10.8.

Contributor

bgrainger commented Jun 2, 2018

For anyone affected by this who wants to stick with MySql.Data, they just announced that this will be fixed in 6.10.8.

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