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

Microsoft.Data.Sqlite: Check error code when binding parameters #32613

Merged
merged 3 commits into from
Dec 15, 2023

Conversation

ajcvickers
Copy link
Member

Fixes #27597

Copy link
Member

@AndriySvyryd AndriySvyryd left a comment

Choose a reason for hiding this comment

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

Consider tagging Eric for these kind of changes

Comment on lines 45 to 49
var sqliteProvider = (ISQLite3Provider)typeof(raw)
.GetProperty("Provider", BindingFlags.Static | BindingFlags.NonPublic)!
.GetValue(null)!;

sqliteProvider.sqlite3_limit(connection.Handle!, 0, 10);
Copy link
Member Author

Choose a reason for hiding this comment

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

@ericsink The "sqlite3_limit" function isn't mapped by default, which is fine, but for this bug I need to call it. Is there a better way of getting hold of the "raw" functions rather than using Reflection like this?

Choose a reason for hiding this comment

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

I'm not sure what you mean by "isn't mapped by default".

sqlite3_limit is in my provider API and is exposed statically by the raw class.

As a sample, my test case for the call looks like this:

        [Fact]
        public void test_call_sqlite3_limit()
        {
            using (sqlite3 db = ugly.open(":memory:"))
            {
                var query = raw.sqlite3_limit(db, raw.SQLITE_LIMIT_LENGTH, -1);
                Assert.True(query >= 0);

                const int limit = 10240;
                var current = raw.sqlite3_limit(db, raw.SQLITE_LIMIT_LENGTH, limit);
                Assert.Equal(query, current);

                query = raw.sqlite3_limit(db, raw.SQLITE_LIMIT_LENGTH, -1);
                Assert.Equal(limit, query);
            }
        }

Copy link
Member Author

Choose a reason for hiding this comment

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

@ericsink Thanks! I totally missed the public static methods!

Choose a reason for hiding this comment

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

No worries. You folks are probably going through ... a transition. :-)

Tag me anytime. Tag me twice if I miss the first one.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks Eric! Appreciate it, as always.

@ajcvickers ajcvickers merged commit cb14437 into main Dec 15, 2023
7 checks passed
@ajcvickers ajcvickers deleted the 231213_MyIdYourId branch December 15, 2023 17:36
@bricelam
Copy link
Contributor

Consider tagging Eric for these kind of changes

And me!

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

Successfully merging this pull request may close these issues.

Wrong ErrorCode reported by SqliteException
4 participants