Skip to content

Commit 2d813ec

Browse files
committed
Fix string attribute type
Was mapped to int64 🙈
1 parent d3554ab commit 2d813ec

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ The macro implementation requires Xcode 15/Swift 5.9 for compilation.
103103
The generated code itself though should backport way back to
104104
iOS 10 / macOS 10.12 though (when `NSPersistentContainer` was introduced).
105105

106+
Package URL:
107+
```
108+
https://github.com/Data-swift/ManagedModels.git
109+
```
110+
111+
ManagedModels has no other dependencies.
112+
106113

107114
#### Differences to SwiftData
108115

Sources/ManagedModels/SchemaCompatibility/NSAttributeDescription+Data.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ extension CoreData.NSAttributeDescription: SchemaProperty {
7373
self.attributeValueClassName = "NSNumber"
7474
}
7575
else if newValue == String.self {
76-
self.attributeType = .integer64AttributeType
76+
self.attributeType = .stringAttributeType
7777
self.isOptional = false
7878
self.attributeValueClassName = "NSString"
7979
}
8080
else if newValue == String?.self {
81-
self.attributeType = .integer64AttributeType
81+
self.attributeType = .stringAttributeType
8282
self.isOptional = true
8383
self.attributeValueClassName = "NSString"
8484
}
@@ -182,16 +182,6 @@ extension CoreData.NSAttributeDescription: SchemaProperty {
182182
self.isOptional = true
183183
self.attributeValueClassName = "NSNumber"
184184
}
185-
else if newValue == Int32.self {
186-
self.attributeType = .integer32AttributeType
187-
self.isOptional = false
188-
self.attributeValueClassName = "NSNumber"
189-
}
190-
else if newValue == Int32?.self {
191-
self.attributeType = .integer32AttributeType
192-
self.isOptional = true
193-
self.attributeValueClassName = "NSNumber"
194-
}
195185
else {
196186
// TBD:
197187
// undefinedAttributeType = 0

Tests/ManagedModelTests/SchemaGenerationTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ final class SchemaGenerationTests: XCTestCase {
2828
XCTAssertTrue (toAddresses.isRelationship)
2929
XCTAssertFalse(toAddresses.isToOneRelationship)
3030

31+
XCTAssertEqual(firstname.attributeType, .stringAttributeType)
32+
XCTAssertTrue(firstname.valueType == String.self)
33+
3134
// Those can't be setup yet.
3235
XCTAssertTrue(toAddresses.destination.isEmpty)
3336
XCTAssertNil(toAddresses.inverseName)

0 commit comments

Comments
 (0)