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.Contrib over MySql/MariaDB fail when use ProfiledDbConnection. #290

Closed
reinaldocoelho opened this issue Jun 8, 2018 · 3 comments
Closed

Comments

@reinaldocoelho
Copy link

I have MiniProfiledDbConnection over a MariaDB connection, and when I will process an INSERT command, the Dapper.Contrib throw an exception.

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '[Id], [CreatedAt], [AndSoOn]' at line 1

Debugging I understand that MiniProfiler change MySqlAdapter to MsSqlAdapter and the insert into command was created with wrong '[, ]' in the field names.

The insert command on MySql is like:

insert into table (field1, field2) values( 1, 'xpto')

But with the change, it is created with MSSQL sintax:

insert into table ([field1], [field2]) values( 1, 'xpto')

Same problem:
https://stackoverflow.com/questions/50581540/dapper-contrib-and-miniprofiler-for-mysql-integration-issues?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

It´s easy to fix that?

@NickCraver
Copy link
Member

I see you're using MiniProfiler 3, is this the same in v4? I would assume it is, as what's happening in Dapper (I'm also one of the maintainers on it as well) is it's looking at the connection type, and the default is SQL Server if we don't recognize it.

I'll take a look next week about how we want to handle this, but I'm just kind of shocked I haven't heard of this before...the problem absolutely makes sense. This would need to be a Dapper change though, not a MiniProfiler one. We're currently working on StackExchange.Redis this month and likely Dapper in the following months...but it's possible we can quick fix this on MyGet at least to unblock you :)

@reinaldocoelho
Copy link
Author

Thank you.
I don't need the solution so fast, my critial use today is in MSSQL and it's not afeted.
But I have made debug on Dapper code and I realize that its receive MSSQL DbApender if I'm using the MiniProfiler, if I remove that from connection, the Dapper.Contrib comes to work well.

If I have some time, and if I found the problem, I create a PullRequest :-)

@NickCraver
Copy link
Member

@reinaldocoelho I'm going to close this out and think about it over on the Dapper side. For now, there is a workaround that allows you to override the connection type resolution in Dapper.Contrib:

SqlMapperExtensions.GetDatabaseType = conn => "MySqlConnection";

Thanks for the Stack Overflow link - I've added and answer there as well :)

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

2 participants