jonwagner / Insight.Database

Fast, lightweight .NET micro-ORM
Other
861 stars 145 forks source link

QuerySql doesn't map parameters into the given query with OleDbInsightDbProvider #369

Closed canro91 closed 6 years ago

canro91 commented 6 years ago

Type

What kind of issue is this?

[x] Bug report.
[ ] Feature request.

Current Behavior

I'm using the OleDbInsightDbProvider to query a DB2 database through a udl file. (These are my business requirements) But when doing a query with QuerySql, the input parameters aren't mapped. And, I get an error saying that I should declare the variables in the query.

Expected behavior

Insight should map the input parameters and run the specified query.

Steps to Reproduce

var filePath = "some udl file to a db2 database";
var conn = new OleDbConnection($"File Name = {filePath}");
conn.QuerySql("SELECT * FROM SCHEMA.TABLE FETCH FIRST @Limit ROWS ONLY", new { Limit = 10 });

Any other comment

After going a little trough the code, the OleDbInsightDbProvider doesn't override the property HasPositionalSqlTextParameters. Is this a intended behavior when using this provider?

Thanks

jonwagner commented 6 years ago

We haven't had a lot of OLEDB usage, so you're probably right that it is a bug in the OLEDB provider.

Do you know if that positional parameters is for all OLEDB drivers or is it driver-dependent?

canro91 commented 6 years ago

Thanks for your answer. I'm not quite sure, but I would say yes, they are for all OLEDB drivers.

jonwagner commented 6 years ago

I was able to reproduce this with the OLEDB driver and fix it in v6.2.3, available in nuget now.