From 5e083a113b3dbed70ba5891905c7dbf6a5f2ec74 Mon Sep 17 00:00:00 2001 From: Di Wu Date: Thu, 14 Mar 2024 15:39:30 -0700 Subject: [PATCH] remove attributeExists operation from QueryFieldOperation --- Amplify/Categories/DataStore/Query/ModelKey.swift | 5 ----- Amplify/Categories/DataStore/Query/QueryField.swift | 7 ------- .../Model/GraphQLDocument/GraphQLListQueryTests.swift | 4 ++-- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/Amplify/Categories/DataStore/Query/ModelKey.swift b/Amplify/Categories/DataStore/Query/ModelKey.swift index 860cb17061..8096bfc9c7 100644 --- a/Amplify/Categories/DataStore/Query/ModelKey.swift +++ b/Amplify/Categories/DataStore/Query/ModelKey.swift @@ -36,11 +36,6 @@ public protocol ModelKey: CodingKey, CaseIterable, QueryFieldOperation {} extension CodingKey where Self: ModelKey { - // MARK: - attributeExists - public func attributeExists(_ value: Bool) -> QueryPredicateOperation { - return field(stringValue).attributeExists(value) - } - // MARK: - beginsWith public func beginsWith(_ value: String) -> QueryPredicateOperation { return field(stringValue).beginsWith(value) diff --git a/Amplify/Categories/DataStore/Query/QueryField.swift b/Amplify/Categories/DataStore/Query/QueryField.swift index 14db836c51..45a9ad8d63 100644 --- a/Amplify/Categories/DataStore/Query/QueryField.swift +++ b/Amplify/Categories/DataStore/Query/QueryField.swift @@ -30,7 +30,6 @@ public func field(_ name: String) -> QueryField { /// - seealso: `ModelKey` public protocol QueryFieldOperation { // MARK: - Functions - func attributeExists(_ value: Bool) -> QueryPredicateOperation func beginsWith(_ value: String) -> QueryPredicateOperation func between(start: Persistable, end: Persistable) -> QueryPredicateOperation func contains(_ value: String) -> QueryPredicateOperation @@ -61,11 +60,6 @@ public struct QueryField: QueryFieldOperation { public let name: String - // MARK: - attributeExists - public func attributeExists(_ value: Bool) -> QueryPredicateOperation { - return .operation(name, .attributeExists(value)) - } - // MARK: - beginsWith public func beginsWith(_ value: String) -> QueryPredicateOperation { return .operation(name, .beginsWith(value)) @@ -167,7 +161,6 @@ public struct QueryField: QueryFieldOperation { .operation(name, .notEqual(value)) ]) } - } public func ne(_ value: EnumPersistable) -> QueryPredicateOperation { diff --git a/AmplifyPlugins/Core/AWSPluginsCoreTests/Model/GraphQLDocument/GraphQLListQueryTests.swift b/AmplifyPlugins/Core/AWSPluginsCoreTests/Model/GraphQLDocument/GraphQLListQueryTests.swift index aa3e8279d2..84f4511b68 100644 --- a/AmplifyPlugins/Core/AWSPluginsCoreTests/Model/GraphQLDocument/GraphQLListQueryTests.swift +++ b/AmplifyPlugins/Core/AWSPluginsCoreTests/Model/GraphQLDocument/GraphQLListQueryTests.swift @@ -231,7 +231,7 @@ class GraphQLListQueryTests: XCTestCase { func test_listQuery_withAttributeExistsFilter_correctlyBuildGraphQLQueryStatement() { let post = Post.keys let predicate = post.id.eq("id") - && (post.draft.attributeExists(false) || post.draft.eq("null")) + && post.draft.eq(nil) var documentBuilder = ModelBasedGraphQLDocumentBuilder(modelSchema: Post.schema, operationType: .query) documentBuilder.add(decorator: DirectiveNameDecorator(type: .list)) @@ -292,7 +292,7 @@ class GraphQLListQueryTests: XCTestCase { }, { "draft" : { - "eq" : "null" + "eq" : null } } ]