Repository navigation
Conversation
Added a method to retrieve enum values from the database.
Added tests for inserting and selecting enum values in Sqlite.
Add a test to verify that enum result types do not trigger warning DAP037.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #228
Root cause
Inspection.IdentifyDbTypedoesn't recognize enum types, so the analyzer treatsQuery<SomeEnum>as a user type with no settable members and reports DAP037 ("Type 'SomeEnum' has no settable fields or properties"). Suppressing the warning worked because the runtime already handles enums:CommandUtils.As<T>converts both numeric values and strings to the enum.Fix
IdentifyDbTypenow maps an enum type to theDbTypeof its underlying type, without advertising a reader method (there is noDbDataReader.GetEnum). Consequences, all desired:Query<SomeEnum>,Query<SomeEnum?>,ExecuteScalar<SomeEnum>, ...)BindResultsByName(matches other scalar results likeint)RowFactory<SomeEnum>(flexible conversion viaCommandUtils.As) instead of a custom empty row factoryEnum members of user types and enum parameters are unchanged: no reader method is advertised for enum members (they still use
GetFieldValue<T>+ flexible fallback), and verified against the SqliteUsage interceptor snapshots.Test plan
DAP037.EnumResultTypesDoNotWarnverifier test (enum, nullable enum, long-backed enum, enum member) - fails before the fix, passes afterSqliteUsageinterceptor scenario extended withQuery<SomeEnum>; regenerated snapshots showRowFactory.Inbuilt.Value<SomeEnum>()SqliteTests.SelectEnumValuesexecutes the intercepted AOT path against in-memory SQLite and asserts the returned enum valuesDapper.AOT.Testrun (net10.0): no regressions; only pre-existing Docker-dependent integration failures (Postgres/MsSqlDateOnlyTimeOnly/BatchPostgresql)