Skip to content

Commit b4991dc

Browse files
committed
Merge branch 'develop'
2 parents 82846f7 + 82b77f6 commit b4991dc

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

Sources/ManagedModels/Container/NSPersistentContainer+Data.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ extension NSPersistentContainer {
1313
//@MainActor - TBD :-)
1414
@inlinable
1515
public var mainContext : NSManagedObjectContext { viewContext }
16+
17+
@inlinable
18+
public var configurations : [ NSPersistentStoreDescription ] {
19+
persistentStoreDescriptions
20+
}
1621

1722
convenience
1823
public init(for model : NSManagedObjectModel,
@@ -29,11 +34,17 @@ extension NSPersistentContainer {
2934
return merged ?? model
3035
}()
3136

37+
var configurations = configurations
38+
if configurations.isEmpty {
39+
configurations.append(Self.defaultConfiguration)
40+
}
41+
3242
// TBD: Is this correct? It is the container name, not the configuration
3343
// name?
3444
let firstName = configurations.first(where: { !$0.name.isEmpty })?.name
3545
?? "ManagedModels"
3646

47+
assert(!configurations.isEmpty)
3748
self.init(
3849
name: firstName,
3950
managedObjectModel: combinedModel
@@ -61,6 +72,14 @@ extension NSPersistentContainer {
6172
viewContext.automaticallyMergesChangesFromParent = true
6273
}
6374

75+
private static var defaultConfiguration : ModelConfiguration {
76+
.init(
77+
path: nil, name: nil, schema: nil,
78+
isStoredInMemoryOnly: false, allowsSave: true,
79+
groupAppContainerIdentifier: nil, cloudKitContainerIdentifier: nil,
80+
groupContainer: .none, cloudKitDatabase: .none
81+
)
82+
}
6483
}
6584

6685
public extension NSPersistentContainer {

Tests/ManagedModelMacrosTests/ManagedModelMacrosTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ final class ModelMacroTests: XCTestCase {
282282
"""
283283
))
284284

285-
#if true
285+
#if false
286286
print("Exploded:---\n")
287287
print(explodedSource)
288288
print("\n-----")
@@ -360,7 +360,7 @@ final class ModelMacroTests: XCTestCase {
360360
"""
361361
))
362362

363-
#if true
363+
#if false
364364
print("Exploded:---\n")
365365
print(explodedSource)
366366
print("\n-----")

0 commit comments

Comments
 (0)