From 7d8164c240142298367b799362672bd0779e5d85 Mon Sep 17 00:00:00 2001 From: Dave Lasley Date: Tue, 18 Oct 2016 18:57:54 -0700 Subject: [PATCH] [FIX] carepoint: Fix sequence generation * Call execute directly on connection to allow params --- carepoint/db/carepoint.py | 2 +- carepoint/tests/db/test_carepoint.py | 4 ++-- setup.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/carepoint/db/carepoint.py b/carepoint/db/carepoint.py index c12235d..16af199 100644 --- a/carepoint/db/carepoint.py +++ b/carepoint/db/carepoint.py @@ -326,7 +326,7 @@ def get_next_sequence(self, sequence_name, db_name='cph'): Integer to use as pk """ with self._get_session(db_name) as session: - res = session.execute( + res = session.connection().execute( text( "SET NOCOUNT ON;" "DECLARE @out int = 0;" diff --git a/carepoint/tests/db/test_carepoint.py b/carepoint/tests/db/test_carepoint.py index c8bc7b0..e8132bd 100644 --- a/carepoint/tests/db/test_carepoint.py +++ b/carepoint/tests/db/test_carepoint.py @@ -293,7 +293,7 @@ def test_get_next_sequence_execute(self, text): expect = 'expect' with mock.patch.object(self.carepoint, '_get_session') as mk: self.carepoint.get_next_sequence(expect) - mk().__enter__().execute.assert_called_once_with( + mk().__enter__().connection().execute.assert_called_once_with( text(), seq_name=expect, ) @@ -301,7 +301,7 @@ def test_get_next_sequence_fetch(self): """ It should return result of fetch """ with mock.patch.object(self.carepoint, '_get_session') as mk: res = self.carepoint.get_next_sequence(None) - expect = mk().__enter__().execute().fetchall()[0][0] + expect = mk().__enter__().connection().execute().fetchall()[0][0] self.assertEqual( expect, res, ) diff --git a/setup.py b/setup.py index f297e29..c375eeb 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ setup_vals = { 'name': 'carepoint', - 'version': '0.1.5', + 'version': '0.1.6', 'author': 'LasLabs Inc.', 'author_email': 'support@laslabs.com', 'description': 'This library will allow you to interact with CarePoint '