Skip to content

Commit

Permalink
Compatibility - change to Dolphin versions of a couple of base methods.
Browse files Browse the repository at this point in the history
testRetrievingIncompatibleClassRaisesError - fix; verify the descriptions of the expected errors.
  • Loading branch information
rko281 committed Dec 18, 2023
1 parent c8d66b5 commit 6de27a4
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions SSW ReStore Tables/Object.extension.st
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,6 @@ Object class >> persistencyRootClass [
^self allSuperclasses detect: [ :sup | sup reStoreTableClass == SSWDBSuperTable]
]

{ #category : #'*SSW ReStore Tables' }
Object >> related [

"Return a related version of the receiver"

^SSWDBRelatedWrapper on: self


]

{ #category : #'*SSW ReStore Tables' }
Object class >> reStoreDefinition [

Expand Down Expand Up @@ -160,6 +150,16 @@ Object class >> reStoreValueClass [
ifFalse: [self reStoreIDClass]
]

{ #category : #'*SSW ReStore Tables' }
Object >> related [

"Return a related version of the receiver"

^SSWDBRelatedWrapper on: self


]

{ #category : #'*SSW ReStore Tables' }
Object class >> shouldInheritPersistency [

Expand Down
4 changes: 1 addition & 3 deletions SSW ReStore Tables/SSWDBInheritedTable.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ SSWDBInheritedTable >> recoverInstanceFromRow: aDBRow into: anSSWDBObjectProxy [

| class |
class := self instanceClassFromRow: aDBRow.
self assert: (class includesBehavior: self instanceClass)
description:
['Proxy for ' , self instanceClass name , ' retrieved a ' , class name , ' from the database.'].
(class includesBehavior: self instanceClass) ifFalse: [self error: 'Proxy for <1d> retrieved a <2d> from the database.' << {self instanceClass. class}].
anSSWDBObjectProxy _class: class.
(class = self instanceClass ifTrue: [self] ifFalse: [self reStore tableForClass: class])
recoverExactClassInstanceFromRow: aDBRow
Expand Down
14 changes: 8 additions & 6 deletions SSW ReStore Tests/SSWReStoreHierarchyTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ SSWReStoreHierarchyTest >> _testClassOfProxyOfInstanceOf: aClass recoveredBy: aB
self assert: proxy _class equals: aClass.

"Check that all declared mutable properties have been properly copied"
aClass mutableAspects withIndexDo:
[:sym :i |
aClass mutableAspects keysAndValuesDo:
[:i :sym |
self deny: (proxy _proxiedObject perform: sym) == (proxy _copyObject perform: sym).
self deny: ((owner midFriend perform: sym) isBitSet: i). "Sanity check, bitmask initializes with 0"
(owner midFriend perform: sym) bitSet: i].
owner midFriend storeIn: reStore.
reStore simulateReconnect.
owner := (MidPerson storedInstancesIn: reStore) detect: [:each | each firstName = 'owner'].
aClass mutableAspects
withIndexDo: [:sym :i | self assert: ((owner midFriend perform: sym) isBitSet: i)].
keysAndValuesDo: [:i :sym | self assert: ((owner midFriend perform: sym) isBitSet: i)]
]

{ #category : #running }
Expand Down Expand Up @@ -335,10 +335,12 @@ SSWReStoreHierarchyTest >> testInheritanceStructureWithoutIntermediateInheritanc
SSWReStoreHierarchyTest >> testRetrievingIncompatibleClassRaisesError [
| detailedID midID |
midID := (reStore instancesOf: MidPerson) first _id.
detailedID := (DetailedPerson1 new storeIn: reStore) _id.
DetailedPerson1 new storeIn: reStore.
detailedID := (reStore instancesOf: DetailedPerson1) first _id.
reStore simulateReconnect.

"Attempt to retrieve what is actually a DetailedPerson as if it were a MidPerson (siblings)"
self should: [(reStore deferredObjectOfClass: MidPerson withID: detailedID) firstName] raise: Error.
self should: [(reStore deferredObjectOfClass: MidPerson withID: detailedID) firstName] raise: Error description: 'Proxy for MidPerson retrieved a DetailedPerson1 from the database.'.
"As above, but parent of the declared class"
self should: [(reStore deferredObjectOfClass: SubPerson withID: midID) firstName] raise: Error.
self should: [(reStore deferredObjectOfClass: SubPerson withID: midID) firstName] raise: Error description: 'Proxy for SubPerson retrieved a MidPerson from the database.'
]

0 comments on commit 6de27a4

Please sign in to comment.