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

SQLA DTO: Explicit error message for cases where a column has no type annotation #1852

Merged
merged 1 commit into from Jun 20, 2023

Conversation

provinzkraut
Copy link
Member

Currently, when a SQLAlchemy DTO is constructed from a model that is missing a type annotation for an included column, a nondescript KeyError is raised.

This adds an ImproperlyConfiguredException with an explicit error message, pointing at the potential issue in these cases.

Pull Request Checklist

  • New code has 100% test coverage
  • (If applicable) The prose documentation has been updated to reflect the changes introduced by this PR
  • (If applicable) The reference documentation has been updated to reflect the changes introduced by this PR

Description

Close Issue(s)

@provinzkraut provinzkraut requested a review from a team as a code owner June 20, 2023 11:56
@sonarcloud
Copy link

sonarcloud bot commented Jun 20, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

@github-actions
Copy link

Documentation preview will be available shortly at https://litestar-org.github.io/litestar-docs-preview/1852

Copy link
Contributor

@peterschutt peterschutt left a comment

Choose a reason for hiding this comment

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

Awesome, thanks for this! One thing I've had in the back of my mind is that we could infer type into from the column/relationship if type hints aren't available - but that's not to take anything away from this, and can be another PR. Thanks!

@provinzkraut
Copy link
Member Author

One thing I've had in the back of my mind is that we could infer type into from the column/relationship if type hints aren't available

That's a good idea! I'll open an issue for this!

@provinzkraut provinzkraut merged commit 7c6e7b3 into main Jun 20, 2023
13 checks passed
@provinzkraut provinzkraut deleted the sqla-dto-no-type-hints-explicit-exception branch June 20, 2023 13:44
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.

None yet

2 participants