-
-
Notifications
You must be signed in to change notification settings - Fork 53
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
Add convenience protocol for enums #112
Conversation
Allow enums to be easily saved and restored from native types, modeled on implementation from SQLite.
Sources/FluentMySQL/MySQLType.swift
Outdated
|
||
/// See `MySQLDataConvertible.convertFromMySQLData(_:)` | ||
public static func convertFromMySQLData(_ data: MySQLData) throws -> Self { | ||
guard let e = try self.init(rawValue: .convertFromMySQLData(data)) else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constant should have a different name. Maybe instance
or extractedCase
? Just something that is more descriptive.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. Someone should likely go back and do that in the SQLite enum code where this was stol... err... got inspiration from?
Sources/FluentMySQL/MySQLType.swift
Outdated
/// Provides a default `MySQLDataConvertible` implementation where the type is also | ||
/// `RawRepresentable` by a `MySQLDataConvertible` type. | ||
extension MySQLDataConvertible | ||
where Self: RawRepresentable, Self.RawValue: MySQLDataConvertible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The line break here should probably be removed. It doesn't match the style of the other declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah -- I think that was a left-over due to the original (SQLite) variant had some much longer things and "had" to be on two lines. But that is no longer the case here...
This is not long enough to require a line break, unlike the original it was taken from.
Use a descriptive name for an assigned constant instead of a single letter name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks!
@calebkleveter do you approve of the changes now? |
Hey @tholo, you just merged a pull request, have a coin! You now have 1 coins. |
Allow enums to be easily saved and restored from native types,
modeled on implementation from SQLite.