Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ca0c85f

Browse files
author
Ross Rogers
committed
Allow user to manually specify left_sql_quote and right_sql_quote. Bandaid fix for issue lionheart#123.
1 parent 9cbdfb7 commit ca0c85f

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ Standard Django settings
133133

134134
Boolean. This will trigger support for Progress Openedge
135135

136+
* ``left_sql_quote`` , ``right_sql_quote``
137+
138+
String. Specifies the string to be inserted for left and right quoting of SQL identifiers respectively. Only set these if django-pyodbc isn't guessing the correct quoting for your system.
139+
140+
136141
OpenEdge Support
137142
~~~~~~~~~~~~~~~~~~~~~~~~
138143
For OpenEdge support make sure you supply both the deiver and the openedge extra options, all other parameters should work the same

django_pyodbc/operations.py

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ def __init__(self, connection):
7373
self._ss_edition = None
7474
self._is_db2 = None
7575
self._is_openedge = None
76+
self._left_sql_quote = None
77+
self._right_sql_quote = None
7678

7779
@property
7880
def is_db2(self):
@@ -90,26 +92,38 @@ def is_db2(self):
9092
def is_openedge(self):
9193
if self._is_openedge is None:
9294
options = self.connection.settings_dict.get('OPTIONS', {})
93-
self._is_openedge = 'openedge' in options and options['openedge']
95+
self._is_openedge = options.get('openedge', False)
9496
return self._is_openedge
9597

9698
@property
9799
def left_sql_quote(self):
98-
if self.is_db2:
99-
return '{'
100-
elif self.is_openedge:
101-
return '"'
102-
else:
103-
return '['
100+
if self._left_sql_quote is None:
101+
options = self.connection.settings_dict.get('OPTIONS', {})
102+
q = options.get('left_sql_quote', None)
103+
if q is not None:
104+
self._left_sql_quote = q
105+
elif self.is_db2:
106+
self._left_sql_quote = '{'
107+
elif self.is_openedge:
108+
self._left_sql_quote = '"'
109+
else:
110+
self._left_sql_quote = '['
111+
return self._left_sql_quote
104112

105113
@property
106114
def right_sql_quote(self):
107-
if self.is_db2:
108-
return '}'
109-
elif self.is_openedge:
110-
return '"'
111-
else:
112-
return ']'
115+
if self._right_sql_quote is None:
116+
options = self.connection.settings_dict.get('OPTIONS', {})
117+
q = options.get('right_sql_quote', None)
118+
if q is not None:
119+
self._right_sql_quote = q
120+
elif self.is_db2:
121+
self._right_sql_quote = '}'
122+
elif self.is_openedge:
123+
self._right_sql_quote = '"'
124+
else:
125+
self._right_sql_quote = ']'
126+
return self._right_sql_quote
113127

114128
def _get_sql_server_ver(self):
115129
"""

0 commit comments

Comments
 (0)