Skip to content

Updates PostgresCastingError to PostgresDecodingError #286

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

Merged
merged 8 commits into from
Apr 27, 2022

Conversation

nicholas-otto
Copy link
Contributor

This updates from PostgresCastingError to PostgresDecodingError and changes associated files. This includes the update to the PostgresErrorTests.swift file in its testPostgresCastingErrorDescription() and the resolution of @usableFromInline tags. I believe it addresses all the issues from the previous pull request Patch 2 #282 and is in response to issue #278.

Copy link
Collaborator

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

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

We are getting closer 🎉. We are missing three publics, at one point the indentations is wrong, and for whatever the reason the script printed a lot of -n.

struct PostgresCastingError: Error, Equatable {
@usableFromInline
struct Code: Hashable, Error {
struct PostgresDecodingError: Error, Equatable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are missing a public here.

@@ -167,7 +155,7 @@ struct PostgresCastingError: Error, Equatable {
}

@usableFromInline
static func ==(lhs: PostgresCastingError, rhs: PostgresCastingError) -> Bool {
static func ==(lhs: PostgresDecodingError, rhs: PostgresDecodingError) -> Bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

we are missing a public here.

Comment on lines 172 to 177
var description: String {
// This may seem very odd... But we are afraid that users might accidentally send the
// unfiltered errors out to end-users. This may leak security relevant information. For this
// reason we overwrite the error description by default to this generic "Database error"
"Database error"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

We are missing a public here. Also this is indented with only 2 spaces.

Comment on lines +68 to +69
echo " } catch let code as PostgresDecodingError.Code {"
echo " throw PostgresDecodingError("
Copy link
Collaborator

Choose a reason for hiding this comment

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

This fix looks correct!

Comment on lines 6 to 10
-n public func decode<T0: PostgresDecodable
-n , JSONDecoder: PostgresJSONDecoder>(_: (T0
-n ).Type, context: PostgresDecodingContext<JSONDecoder>, file: String = #file, line: Int = #line) throws
-n -> (T0
) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why does echo suddenly print the -n. @gwynne do you have an idea why this might be happening?

@nicholas-otto
Copy link
Contributor Author

I believe the pull request has been updated with the previous changes including a fix to the -n issue caused by dev/generate-postgresrow-multi-decode.sh

@fabianfett
Copy link
Collaborator

Awesome! this looks much better already! However CI is still failing. Looks like a find & replace for the remaining usages of: PostgresCastingError would be the right approach now!

@fabianfett
Copy link
Collaborator

@nicholas-otto We are nearly there! Looks like you ran into a small typo: PostgresDecoingError instead of PostgresDecodingError. If the project builds for you locally you should be good. You can call swift build --build-tests or just build in Xcode.

Copy link
Collaborator

@fabianfett fabianfett left a comment

Choose a reason for hiding this comment

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

Great change! Thank you!

@fabianfett fabianfett merged commit a7a160b into vapor:main Apr 27, 2022
@fabianfett fabianfett added this to the 1.10.0 milestone Apr 27, 2022
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.

2 participants