Skip to content

Commit 64dbf27

Browse files
committed
iteration instead of property
1 parent 6a6c4c3 commit 64dbf27

5 files changed

Lines changed: 14 additions & 15 deletions

File tree

‎plsql/client.py‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def __init__(self, plsql, name, owner, object_id, subprogram_id):
4646

4747
binds = {'owner': self.owner, 'object_name': self.definition.object_name,
4848
'object_id': self.object_id, 'subprogram_id': self.subprogram_id}
49-
self.arguments = list(plsql.query(sql_query=self.argument_sql, bind_variables=binds).all)
49+
self.arguments = list(plsql.query(sql_query=self.argument_sql, bind_variables=binds))
5050

5151
try:
5252
self.return_type = next(
@@ -168,7 +168,7 @@ def resolve_subprogram(attributes, parameters, plsql):
168168
'''
169169

170170
binds = {'owner': schema, 'name': package, 'procedure_name': subprogram}
171-
matching_subprograms = list(plsql.query(subprogram_sql, binds).all)
171+
matching_subprograms = list(plsql.query(subprogram_sql, binds))
172172
if len(matching_subprograms) > 1:
173173
raise NotImplementedError('Can not resolve to single subprogram!')
174174

@@ -188,7 +188,7 @@ def resolve_subprogram(attributes, parameters, plsql):
188188
AND object_type IN ('FUNCTION', 'PROCEDURE', 'PACKAGE')
189189
'''
190190
binds = {'name': object_name, 'procedure_name': procedure_name}
191-
matching_subprograms = list(plsql.query(subprogram_sql, binds).all)
191+
matching_subprograms = list(plsql.query(subprogram_sql, binds))
192192

193193
if len(matching_subprograms) > 1:
194194
raise NotImplementedError('Can not resolve to single subprogram!')
@@ -204,7 +204,7 @@ def resolve_subprogram(attributes, parameters, plsql):
204204
'''
205205
owner, object_name = attributes
206206
binds = {'owner': owner, 'name': object_name}
207-
matching_subprograms = list(plsql.query(subprogram_sql, binds).all)
207+
matching_subprograms = list(plsql.query(subprogram_sql, binds))
208208
if len(matching_subprograms) > 1:
209209
raise NotImplementedError('Can not resolve to single subprogram!')
210210

@@ -219,7 +219,7 @@ def resolve_subprogram(attributes, parameters, plsql):
219219
'''
220220
subprogram, = attributes
221221

222-
matching_subprograms = list(plsql.query(subprogram_sql, {'name': subprogram}).all)
222+
matching_subprograms = list(plsql.query(subprogram_sql, {'name': subprogram}))
223223

224224
if not matching_subprograms:
225225
raise AttributeError('No such subprogram exists!')
@@ -272,8 +272,7 @@ def first(self):
272272
first_row = next(self.execute())
273273
return first_row
274274

275-
@property
276-
def all(self):
275+
def __iter__(self):
277276
return self.execute()
278277

279278

‎tests/sql/function/function_blob.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ RETURN BLOB IS
33
v_blob BLOB;
44
BEGIN
55
dbms_lob.createtemporary(v_blob, TRUE);
6-
FOR i IN 1 .. 10000 LOOP
6+
FOR i IN 1 .. 1000 LOOP
77
DBMS_LOB.APPEND(v_blob, p_blob);
88
END LOOP;
99

‎tests/sql/function/function_clob.sql‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CREATE OR REPLACE FUNCTION function_clob(p_clob IN OUT CLOB)
22
RETURN CLOB IS
33
v_clob CLOB;
44
BEGIN
5-
FOR i IN 1 .. 10000 LOOP
5+
FOR i IN 1 .. 1000 LOOP
66
v_clob := v_clob || p_clob;
77
END LOOP;
88

‎tests/test_functions.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_function_clob(plsql):
4444
result, in_out = plsql.function_clob(p_clob=clob)
4545
result, in_out['p_clob'] = result.read(), in_out['p_clob'].read()
4646

47-
assert len(result) == len(in_out['p_clob']) == 10000
47+
assert len(result) == len(in_out['p_clob']) == 1000
4848
assert type(clob) == type(result) == type(in_out['p_clob'])
4949

5050

@@ -53,5 +53,5 @@ def test_function_blob(plsql):
5353
result, in_out = plsql.function_blob(p_blob=blob)
5454
result, in_out['p_blob'] = result.read(), in_out['p_blob'].read()
5555

56-
assert len(result) == len(in_out['p_blob']) == 10000
56+
assert len(result) == len(in_out['p_blob']) == 1000
5757
assert type(blob) == type(result) == type(in_out['p_blob'])

‎tests/test_query.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def test_dual_single_column(plsql):
44
FROM dual'''
55

66
assert plsql.query(query).first == 1
7-
assert list(plsql.query(query).all) == [1]
7+
assert list(plsql.query(query)) == [1]
88

99

1010
def test_dual_multiple_column(plsql):
@@ -13,7 +13,7 @@ def test_dual_multiple_column(plsql):
1313
SELECT 1 AS int, '2' AS string, 3.5 AS num FROM dual
1414
'''
1515
first_row = plsql.query(query).first
16-
all_rows = list(plsql.query(query).all)
16+
all_rows = list(plsql.query(query))
1717

1818
def assert_assumptions(single_row):
1919
assert len(single_row) == 3
@@ -40,7 +40,7 @@ def test_larger_query(plsql):
4040

4141
assert query_generator.first == 1
4242

43-
for row, expected in zip(query_generator.all, range(1, 1000)):
43+
for row, expected in zip(query_generator, range(1, 1000)):
4444
assert row == expected
4545

46-
assert len(list(query_generator.all)) == 1000
46+
assert len(list(query_generator)) == 1000

0 commit comments

Comments
 (0)