Skip to content

Commit 89d294c

Browse files
authored
Merge pull request #163 from lopezca/fix-proxy-class-bug
Fix proxy class bug
2 parents 6afdd85 + 1a1a8bd commit 89d294c

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

src/Glorp-Integration-Tests/GlorpProxyTest.class.st

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Class {
33
#superclass : #GlorpTestCase,
44
#instVars : [
55
'session',
6-
'proxy'
6+
'proxy',
7+
'result'
78
],
89
#category : #'Glorp-Integration-Tests-Database'
910
}
@@ -23,7 +24,8 @@ GlorpProxyTest >> setUp [
2324
proxy := Proxy new.
2425
proxy session: session.
2526
stub := GlorpQueryStub readOneOf: GlorpAddress where: [:address | address id = 1].
26-
stub result: 42.
27+
result:= GlorpAddress new.
28+
stub result: result.
2729
proxy query: stub.
2830
proxy parameters: #()
2931
]
@@ -55,7 +57,7 @@ GlorpProxyTest >> testCreation [
5557
GlorpProxyTest >> testInstantiationFromStub [
5658

5759
self assert: (proxy getValue notNil).
58-
self assert: proxy = 42.
60+
self assert: proxy equals: result.
5961
self assert: proxy isInstantiated.
6062
]
6163

@@ -77,3 +79,20 @@ GlorpProxyTest >> testPrintingUninstantiatedCollection [
7779
proxy query readsOneObject: false.
7880
self assert: proxy printString = '{uninstantiated collection of GlorpAddress}'.
7981
]
82+
83+
{ #category : #tests }
84+
GlorpProxyTest >> testSpecies [
85+
86+
self assert: proxy species equals: GlorpAddress
87+
]
88+
89+
{ #category : #tests }
90+
GlorpProxyTest >> testSpeciesisProxy [
91+
"a proxy without a result or a query returns Proxy as species"
92+
93+
| prox |
94+
95+
prox := Proxy new.
96+
97+
self assert: prox species equals: Proxy
98+
]

src/Glorp/PharoDatabaseAccessor.class.st

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ PharoDatabaseAccessor >> databaseDriver: aDriver [
124124
{ #category : #executing }
125125
PharoDatabaseAccessor >> disconnect [
126126

127-
^ self connection disconnect
127+
^ self connection ifNotNil: [ :conn | conn disconnect ]
128128
]
129129

130130
{ #category : #accessing }

src/Glorp/Proxy.class.st

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,13 @@ Proxy >> session: aSession [
208208

209209
{ #category : #accessing }
210210
Proxy >> species [
211+
"returns the class of the proxied object either by looking at the actual value's class"
212+
"or the expected result of the proxy. Returns Proxy otherwise."
211213

212214
self isInstantiated ifTrue: [^value species].
213215
query isNil ifTrue: [^Proxy].
214-
query resultClass isNil ifTrue: [^Proxy].
215-
^query resultClass species
216+
"self traceCr: 'not instantiated'."
217+
^ query resultClass ifNil: [ Proxy ]
218+
216219

217220
]

0 commit comments

Comments
 (0)