Skip to content

Commit f5e6701

Browse files
authored
fix(api): Fix getPrimaryKeyString for non-string CPK with no sort keys (#2502)
1 parent 722b4cb commit f5e6701

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

core/src/main/java/com/amplifyframework/core/model/Model.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,8 @@ default String getPrimaryKeyString() {
6969
try {
7070
if (resolveIdentifier() instanceof ModelIdentifier) {
7171
return ((ModelIdentifier<?>) resolveIdentifier()).getIdentifier();
72-
} else if (resolveIdentifier() instanceof String) {
73-
return (String) resolveIdentifier();
7472
} else {
75-
return ModelIdentifier.Helper.escapeAndEncapsulateString(
76-
resolveIdentifier().toString()
77-
);
73+
return resolveIdentifier().toString();
7874
}
7975
} catch (Exception exception) {
8076
throw (new IllegalStateException("Invalid Primary Key", exception));

core/src/test/java/com/amplifyframework/core/model/ModelIdentifierTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class ModelIdentifierTest {
4444
@Test
4545
fun cpk_non_string_without_model_identifier_with_no_sort_key() {
4646
val expectedKey = 123
47-
val expectedKeyString = "\"123\""
47+
val expectedKeyString = "123"
4848

4949
val identifier = IntModelWithoutIdentifier.builder().customId(expectedKey).build().primaryKeyString
5050

0 commit comments

Comments
 (0)