-
Notifications
You must be signed in to change notification settings - Fork 227
fix(amplify): DataStore query fix column missing issue for @connection belongsTo schema #885
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
f571744
fixed failed syncEventEmitterTests
618coffee 6841bfa
Merge branch 'main' of https://github.com/aws-amplify/amplify-ios int…
618coffee 7fe77b4
Merge branch 'main' of https://github.com/aws-amplify/amplify-ios int…
618coffee 2c48d18
Merge branch 'main' of https://github.com/aws-amplify/amplify-ios int…
618coffee 1844fc5
Merge branch 'main' of https://github.com/aws-amplify/amplify-ios int…
618coffee 4c8b6a2
PR of correcting columnname for connection schema
618coffee 407cbbc
update AWSPluginsCore
618coffee ad6ebf4
remove a force unwrap
618coffee edb7d8f
added codingkeystests
618coffee 9ac7b6c
Merge branch 'main' into fix/columnmissing
618coffee be4abb4
ModelKey protocol: changed from Model.Type to String
618coffee 2ee40ca
added default implementation
618coffee ca250b8
updated struct that conforms to Model
618coffee 17cbe3b
updated struct that conforms to Model
618coffee 6ca393f
added two more tests and revert the changes in Podfile.lock
618coffee 9cb73e2
foratted graphql
618coffee fef2f1f
added a print to output warning
618coffee f06b54f
ModelKey conforms to DefaultLogger
618coffee 278a8c1
removed one unit test in GraphQLListTest
618coffee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,24 +32,43 @@ import Foundation | |
| /// post.content != nil | ||
| /// }) | ||
| /// ``` | ||
| public protocol ModelKey: CodingKey, CaseIterable, QueryFieldOperation {} | ||
| public protocol ModelKey: CodingKey, CaseIterable, QueryFieldOperation, DefaultLogger { | ||
| var modelName: String { get } | ||
| } | ||
|
|
||
| extension ModelKey { | ||
| public var modelName: String { "" } | ||
| } | ||
|
|
||
| extension CodingKey where Self: ModelKey { | ||
|
|
||
| var columnName: String { | ||
| guard let modelSchema: ModelSchema = ModelRegistry.modelSchema(from: modelName) else { | ||
lawmicha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| log.warn("Please upgrade to the latest version of Amplify CLI and rerun `amplify codegen models`") | ||
| return stringValue | ||
618coffee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| switch modelSchema.field(withName: stringValue)?.association { | ||
| case .belongsTo(_, let targetName): | ||
| return targetName ?? stringValue | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We seem to have a unit tests which tests when targetName is not nil, but we should add a test where targetName is nil, so that it just returns the regular |
||
| default: | ||
| return stringValue | ||
lawmicha marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| // MARK: - beginsWith | ||
| public func beginsWith(_ value: String) -> QueryPredicateOperation { | ||
| return field(stringValue).beginsWith(value) | ||
| return field(columnName).beginsWith(value) | ||
| } | ||
|
|
||
| // MARK: - between | ||
| public func between(start: Persistable, end: Persistable) -> QueryPredicateOperation { | ||
| return field(stringValue).between(start: start, end: end) | ||
| return field(columnName).between(start: start, end: end) | ||
| } | ||
|
|
||
| // MARK: - contains | ||
|
|
||
| public func contains(_ value: String) -> QueryPredicateOperation { | ||
| return field(stringValue).contains(value) | ||
| return field(columnName).contains(value) | ||
| } | ||
|
|
||
| public static func ~= (key: Self, value: String) -> QueryPredicateOperation { | ||
|
|
@@ -59,11 +78,11 @@ extension CodingKey where Self: ModelKey { | |
| // MARK: - eq | ||
|
|
||
| public func eq(_ value: Persistable?) -> QueryPredicateOperation { | ||
| return field(stringValue).eq(value) | ||
| return field(columnName).eq(value) | ||
| } | ||
|
|
||
| public func eq(_ value: EnumPersistable) -> QueryPredicateOperation { | ||
| return field(stringValue).eq(value) | ||
| return field(columnName).eq(value) | ||
| } | ||
|
|
||
| public static func == (key: Self, value: Persistable?) -> QueryPredicateOperation { | ||
|
|
@@ -77,7 +96,7 @@ extension CodingKey where Self: ModelKey { | |
| // MARK: - ge | ||
|
|
||
| public func ge(_ value: Persistable) -> QueryPredicateOperation { | ||
| return field(stringValue).ge(value) | ||
| return field(columnName).ge(value) | ||
| } | ||
|
|
||
| public static func >= (key: Self, value: Persistable) -> QueryPredicateOperation { | ||
|
|
@@ -87,7 +106,7 @@ extension CodingKey where Self: ModelKey { | |
| // MARK: - gt | ||
|
|
||
| public func gt(_ value: Persistable) -> QueryPredicateOperation { | ||
| return field(stringValue).gt(value) | ||
| return field(columnName).gt(value) | ||
| } | ||
|
|
||
| public static func > (key: Self, value: Persistable) -> QueryPredicateOperation { | ||
|
|
@@ -97,7 +116,7 @@ extension CodingKey where Self: ModelKey { | |
| // MARK: - le | ||
|
|
||
| public func le(_ value: Persistable) -> QueryPredicateOperation { | ||
| return field(stringValue).le(value) | ||
| return field(columnName).le(value) | ||
| } | ||
|
|
||
| public static func <= (key: Self, value: Persistable) -> QueryPredicateOperation { | ||
|
|
@@ -107,7 +126,7 @@ extension CodingKey where Self: ModelKey { | |
| // MARK: - lt | ||
|
|
||
| public func lt(_ value: Persistable) -> QueryPredicateOperation { | ||
| return field(stringValue).lt(value) | ||
| return field(columnName).lt(value) | ||
| } | ||
|
|
||
| public static func < (key: Self, value: Persistable) -> QueryPredicateOperation { | ||
|
|
@@ -117,11 +136,11 @@ extension CodingKey where Self: ModelKey { | |
| // MARK: - ne | ||
|
|
||
| public func ne(_ value: Persistable?) -> QueryPredicateOperation { | ||
| return field(stringValue).ne(value) | ||
| return field(columnName).ne(value) | ||
| } | ||
|
|
||
| public func ne(_ value: EnumPersistable) -> QueryPredicateOperation { | ||
| return field(stringValue).ne(value) | ||
| return field(columnName).ne(value) | ||
| } | ||
|
|
||
| public static func != (key: Self, value: Persistable?) -> QueryPredicateOperation { | ||
|
|
||
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
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
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
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
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
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
Oops, something went wrong.
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.
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.
document the behavior. Why is it empty by default? (i.e. explain the backward compatibility)