Skip to content

Commit 05beb78

Browse files
authored
remove useless collect message send in SQLite3Table>>#rows. fix: #71 (#72)
and add some tests.
1 parent 1ad6c1d commit 05beb78

File tree

2 files changed

+33
-5
lines changed

2 files changed

+33
-5
lines changed

Diff for: src/SQLite3-Core-Tests/SQLite3TableTest.class.st

+30
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,36 @@ SQLite3TableTest >> testPrintString [
7474
self assert: table printString equals: 'a SQLite3Table("SAMPLE")'
7575
]
7676

77+
{ #category : #'tests - sample' }
78+
SQLite3TableTest >> testRows [
79+
80+
self assert: table rows isEmpty
81+
]
82+
83+
{ #category : #'tests - sample' }
84+
SQLite3TableTest >> testRowsHasOneRow [
85+
86+
| rows |
87+
db execute: 'INSERT INTO SAMPLE(NAME) VALUES (''first example'');'.
88+
rows := table rows.
89+
self deny: rows isEmpty.
90+
self assert: rows size equals: 1.
91+
self assert: (rows first at: 'NAME') equals: 'first example'
92+
]
93+
94+
{ #category : #'tests - sample' }
95+
SQLite3TableTest >> testRowsHasTwoRows [
96+
97+
| rows |
98+
db execute:
99+
'INSERT INTO SAMPLE(NAME) VALUES (''first example''), (''second example'');'.
100+
rows := table rows.
101+
self deny: rows isEmpty.
102+
self assert: rows size equals: 2.
103+
self assert: (rows first at: 'NAME') equals: 'first example'.
104+
self assert: (rows second at: 'NAME') equals: 'second example'
105+
]
106+
77107
{ #category : #'tests - sample' }
78108
SQLite3TableTest >> testSampleTable [
79109

Diff for: src/SQLite3-Core/SQLite3Table.class.st

+3-5
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,9 @@ SQLite3Table >> properties: anObject [
8484
{ #category : #accessing }
8585
SQLite3Table >> rows [
8686

87-
^ self database
88-
execute: 'SELECT *
89-
FROM ', self name, '
90-
LIMIT 1000;'
91-
doing: [ :result | result rows collect: [ :each | each ] ]
87+
^ (self database execute: 'SELECT *
88+
FROM ' , self name , '
89+
LIMIT 1000;') rows
9290
]
9391

9492
{ #category : #accessing }

0 commit comments

Comments
 (0)