Skip to content

Add a setting to turn off Ole Db "smell check" - #1974

Merged
mgravell merged 6 commits into
DapperLib:mainfrom
Giorgi:Skip-OleDb-Check
Oct 11, 2023
Merged

Add a setting to turn off Ole Db "smell check"#1974
mgravell merged 6 commits into
DapperLib:mainfrom
Giorgi:Skip-OleDb-Check

Conversation

@Giorgi

Copy link
Copy Markdown
Contributor

Implements #1971

@mgravellmgravell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a few comments inline; needs some kind of test; this is a little awkward because of concurrency concerns, but we should at least try

Comment threadDapper/SqlMapper.cs Outdated
Comment threadDapper/SqlMapper.Settings.cs Outdated
@Giorgi

Copy link
Copy Markdown
ContributorAuthor

I think it now should work correctly in both cases but I'm not sure how to test it.

@Giorgi
Giorgi requested a review from mgravellOctober 10, 2023 10:47
Comment threadDapper/SqlMapper.cs Outdated
@mgravell

Copy link
Copy Markdown
Member

Re testing; IIRC in the original ticket there was an example where it did the wrong thing; can we not just use something based on that to show it continuing to fail when set to true and working when set to false? The only caveat is that we should use try/finally to set the value back to what it was originally after the test

@Giorgi

Copy link
Copy Markdown
ContributorAuthor

I tried #1914 and it still throws the same exception.

@mgravell

mgravell commented Oct 10, 2023

Copy link
Copy Markdown
Member

I tried #1914 and it still throws the same exception.

well yes, but that is a different glitch; I wouldn't expect that to change, so it is good that it didn't - however, we should be able to validate with a scenario more like #1971 - for example:

[Theory][InlineData(true)][InlineData(false)]publicvoidOleDbParamFilterFails(boolyourNewSettingHere){varoldValue=SqlMapper.Settings.YourNewSettingHere;try{SqlMapper.Settings.YourNewSettingHere=yourNewSettingHere;if(yourNewSettingHere)// OLE DB parameter support enabled; can false-positive{Assert.Throws<NotImplementedException>(()=>GetValue(connection));}else// OLE DB parameter support disabled; more reliable{Assert.Equal("this ? could be awkward",GetValue(connection));}}finally{SqlMapper.Settings.YourNewSettingHere=oldValue;}staticstringGetValue(DbConnectionconnection)=>connection.QuerySingle<string>("select 'this ? could be awkward'",newTypeWithDodgyProperties());}classTypeWithDodgyProperties{publicstringName=>thrownewNotSupportedException();}

I haven't executed that at all, note

@GiorgiGiorgi closed this Oct 10, 2023
@Giorgi
Giorgi deleted the Skip-OleDb-Check branch October 10, 2023 14:40
@GiorgiGiorgi reopened this Oct 10, 2023
@Giorgi
Giorgi requested a review from mgravellOctober 10, 2023 15:29
@mgravell

Copy link
Copy Markdown
Member

looks good; can you add a release-note entry? for an example see index.md here: a37b151#diff-b4d68dc855d0f9476d3f2ee343853bd21bf82ea9960d0cf06661baa244439dd6

@mgravell

Copy link
Copy Markdown
Member

also, can you confirm you're free and willing to contribute this code irrevocably etc in line with the project license, i.e. "don't sue me later"

@mgravell

Copy link
Copy Markdown
Member

Note: re the pseudo-positional parameter support (#1914) - that's one that Dapper.Analyzer will definitely be helping with ASAP; the problem is that we don't want to have to constantly parse SQL, so for @foo and ?foo?, at runtime we kinda have to do things the "probably" way; however, Dapper.Analyzer can take the time at build to do a full parse, find the actual parameters, and offer a warning and advice on workarounds. So if that one is hurting you: worry not!

@Giorgi

Copy link
Copy Markdown
ContributorAuthor

looks good; can you add a release-note entry? for an example see index.md here: a37b151#diff-b4d68dc855d0f9476d3f2ee343853bd21bf82ea9960d0cf06661baa244439dd6

Under the ### unreleased section?

@Giorgi

Copy link
Copy Markdown
ContributorAuthor

also, can you confirm you're free and willing to contribute this code irrevocably etc in line with the project license, i.e. "don't sue me later"

I confirm

@mgravell
mgravell merged commit 19193b5 into DapperLib:mainOct 11, 2023
@mgravell

Copy link
Copy Markdown
Member

Merged with thanks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Giorgi@mgravell