Skip to content

Commit

Permalink
Removing support for parameters in queries
Browse files Browse the repository at this point in the history
  • Loading branch information
vish689 committed May 10, 2024
1 parent 58c8bb7 commit a72e7b1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion salesforcecdpconnector/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

apilevel = "2.0"
threadsafety = 2
paramstyle = "qmark"
paramstyle = None


class SalesforceCDPConnection:
Expand Down
9 changes: 2 additions & 7 deletions salesforcecdpconnector/cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,8 @@ def _resolve_query_with_params(self, query, params):
if params is None and params_count_from_query == 0:
return query

if self._is_iterable(params) and params_count_from_query == len(params):
for param in params:
query = self._replace_next_param(query, param)
elif params_count_from_query == 1 and params is not None:
query = self._replace_next_param(query, params)
else:
raise Exception('Parameter count not matching')
if params:
raise Exception('Parameters are not supported')

return query

Expand Down
7 changes: 7 additions & 0 deletions tests/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,12 @@ def test_fetchoneendingwithemptybatch(self, mock1, mock2):
self.assertEqual(len(all_records), 3)
cursor.close()

def test_params_fail(self):
connection = SalesforceCDPConnection('login_url', 'username', 'password', 'client_id', 'client_secret')
cursor = connection.cursor()
with self.assertRaises(Exception) as context:
cursor.execute("select * from UnifiedIndividuals__dlm where col__c = ?", ['test'])
self.assertTrue("Parameters are not supported" in context.exception.args)

if __name__ == '__main__':
unittest.main()

0 comments on commit a72e7b1

Please sign in to comment.