Skip to content

Commit b33e52b

Browse files
author
Greg Turnquist
committed
Merge branch '1.1.x' into 1.2.x
2 parents 59ac69c + 34a30e4 commit b33e52b

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

src/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
setup.py
2+
springpython.egg-info

src/springpython/database/core.py

+4
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ def __del__(self):
5252

5353
def _execute(self, sql_statement, args = None):
5454
"""Issue a single SQL execute, typically a DDL statement."""
55+
56+
if args and type(args) not in self.connection_factory.acceptable_types:
57+
raise InvalidArgumentType(type(args), self.connection_factory.acceptable_types)
58+
5559
sql_statement = self.connection_factory.convert_sql_binding(sql_statement)
5660

5761
cursor = self.connection_factory.getConnection().cursor()

test/springpythontest/databaseCoreTestCases.py

+32
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,38 @@ def testQueryingOracleWithValidlyFormattedArguments(self):
131131

132132
del(sys.modules["cx_Oracle"])
133133

134+
def testInsertingIntoOracleWithInvalidlyFormattedArguments(self):
135+
cursor = self.mock()
136+
conn = self.mock()
137+
138+
sys.modules["cx_Oracle"] = self.mock()
139+
sys.modules["cx_Oracle"].expects(once()).method("connect").will(return_value(conn))
140+
141+
connection_factory = factory.cxoraConnectionFactory(username="foo", password="bar", hostname="localhost", db="mock")
142+
dt = DatabaseTemplate(connection_factory)
143+
144+
self.assertRaises(InvalidArgumentType, dt.execute,
145+
"INSERT INTO T_UNIT (F_UNIT_PK, F_UNIT_ID, F_NAME) VALUES (?, ?, ?)",
146+
(1,1,1))
147+
148+
del(sys.modules["cx_Oracle"])
149+
150+
def testInsertingIntoOracleWithInvalidlyFormattedArgumentsWithUpdateApi(self):
151+
cursor = self.mock()
152+
conn = self.mock()
153+
154+
sys.modules["cx_Oracle"] = self.mock()
155+
sys.modules["cx_Oracle"].expects(once()).method("connect").will(return_value(conn))
156+
157+
connection_factory = factory.cxoraConnectionFactory(username="foo", password="bar", hostname="localhost", db="mock")
158+
dt = DatabaseTemplate(connection_factory)
159+
160+
self.assertRaises(InvalidArgumentType, dt.update,
161+
"INSERT INTO T_UNIT (F_UNIT_PK, F_UNIT_ID, F_NAME) VALUES (?, ?, ?)",
162+
(1,1,1))
163+
164+
del(sys.modules["cx_Oracle"])
165+
134166
class DatabaseTemplateMockTestCase(MockTestCase):
135167
"""Testing the DatabaseTemplate utilizes stubbing and mocking, in order to isolate from different
136168
vendor implementations. This reduces the overhead in making changes to core functionality."""

0 commit comments

Comments
 (0)