@@ -24,55 +24,56 @@ def ignore(*args, **kwargs):
2424class DatabaseClient (BaseDatabaseClient ):
2525 runshell = ignore
2626
27+
2728class DatabaseWrapper (BaseDatabaseWrapper ):
28- vendor = ' intersystems'
29- display_name = ' InterSystems IRIS'
29+ vendor = " intersystems"
30+ display_name = " InterSystems IRIS"
3031
3132 data_types = {
32- ' AutoField' : ' IDENTITY' ,
33- ' BigAutoField' : ' IDENTITY' ,
34- ' BinaryField' : ' LONG BINARY' ,
35- ' BooleanField' : ' BIT' ,
36- ' CharField' : ' VARCHAR(%(max_length)s)' ,
37- ' DateField' : ' DATE' ,
38- ' DateTimeField' : ' TIMESTAMP' ,
39- ' DecimalField' : ' NUMERIC(%(max_digits)s, %(decimal_places)s)' ,
40- ' DurationField' : ' BIGINT' ,
41- ' FileField' : ' VARCHAR(%(max_length)s)' ,
42- ' FilePathField' : ' VARCHAR(%(max_length)s)' ,
43- ' FloatField' : ' DOUBLE PRECISION' ,
44- ' IntegerField' : ' INTEGER' ,
45- ' BigIntegerField' : ' BIGINT' ,
46- ' IPAddressField' : ' CHAR(15)' ,
47- ' GenericIPAddressField' : ' CHAR(39)' ,
48- ' JSONField' : ' VARCHAR(32768)' ,
49- ' OneToOneField' : ' INTEGER' ,
50- ' PositiveBigIntegerField' : ' BIGINT' ,
51- ' PositiveIntegerField' : ' INTEGER' ,
52- ' PositiveSmallIntegerField' : ' SMALLINT' ,
53- ' SlugField' : ' VARCHAR(%(max_length)s)' ,
54- ' SmallAutoField' : ' IDENTITY' ,
55- ' SmallIntegerField' : ' SMALLINT' ,
56- ' TextField' : ' TEXT' ,
57- ' TimeField' : ' TIME(6)' ,
58- ' UUIDField' : 'CHAR(32)' ,
33+ " AutoField" : " IDENTITY" ,
34+ " BigAutoField" : " IDENTITY" ,
35+ " BinaryField" : " LONG BINARY" ,
36+ " BooleanField" : " BIT" ,
37+ " CharField" : " VARCHAR(%(max_length)s)" ,
38+ " DateField" : " DATE" ,
39+ " DateTimeField" : " TIMESTAMP" ,
40+ " DecimalField" : " NUMERIC(%(max_digits)s, %(decimal_places)s)" ,
41+ " DurationField" : " BIGINT" ,
42+ " FileField" : " VARCHAR(%(max_length)s)" ,
43+ " FilePathField" : " VARCHAR(%(max_length)s)" ,
44+ " FloatField" : " DOUBLE PRECISION" ,
45+ " IntegerField" : " INTEGER" ,
46+ " BigIntegerField" : " BIGINT" ,
47+ " IPAddressField" : " CHAR(15)" ,
48+ " GenericIPAddressField" : " CHAR(39)" ,
49+ " JSONField" : " VARCHAR(32768)" ,
50+ " OneToOneField" : " INTEGER" ,
51+ " PositiveBigIntegerField" : " BIGINT" ,
52+ " PositiveIntegerField" : " INTEGER" ,
53+ " PositiveSmallIntegerField" : " SMALLINT" ,
54+ " SlugField" : " VARCHAR(%(max_length)s)" ,
55+ " SmallAutoField" : " IDENTITY" ,
56+ " SmallIntegerField" : " SMALLINT" ,
57+ " TextField" : " TEXT" ,
58+ " TimeField" : " TIME(6)" ,
59+ " UUIDField" : "UNIQUEIDENTIFIER" ,
5960 }
6061
6162 operators = {
62- ' exact' : ' = %s' ,
63- ' iexact' : "LIKE %s ESCAPE '\\ '" ,
64- ' contains' : "LIKE %s ESCAPE '\\ '" ,
65- ' icontains' : "LIKE %s ESCAPE '\\ '" ,
63+ " exact" : " = %s" ,
64+ " iexact" : "LIKE %s ESCAPE '\\ '" ,
65+ " contains" : "LIKE %s ESCAPE '\\ '" ,
66+ " icontains" : "LIKE %s ESCAPE '\\ '" ,
6667 # 'regex': "%%%%MATCHES %s ESCAPE '\\'",
6768 # 'iregex': "%%%%MATCHES %s ESCAPE '\\'",
68- 'gt' : ' > %s' ,
69- ' gte' : ' >= %s' ,
70- 'lt' : ' < %s' ,
71- ' lte' : ' <= %s' ,
72- ' startswith' : "LIKE %s ESCAPE '\\ '" ,
73- ' endswith' : "LIKE %s ESCAPE '\\ '" ,
74- ' istartswith' : "LIKE %s ESCAPE '\\ '" ,
75- ' iendswith' : "LIKE %s ESCAPE '\\ '" ,
69+ "gt" : " > %s" ,
70+ " gte" : " >= %s" ,
71+ "lt" : " < %s" ,
72+ " lte" : " <= %s" ,
73+ " startswith" : "LIKE %s ESCAPE '\\ '" ,
74+ " endswith" : "LIKE %s ESCAPE '\\ '" ,
75+ " istartswith" : "LIKE %s ESCAPE '\\ '" ,
76+ " iendswith" : "LIKE %s ESCAPE '\\ '" ,
7677 }
7778
7879 pattern_esc = r"REPLACE(REPLACE(REPLACE({}, '\', '\\'), '%%', '\%%'), '_', '\_')"
@@ -83,7 +84,6 @@ class DatabaseWrapper(BaseDatabaseWrapper):
8384 "istartswith" : "LIKE UPPER({}) || '%%'" ,
8485 "endswith" : "LIKE '%%' || {}" ,
8586 "iendswith" : "LIKE '%%' || UPPER({})" ,
86-
8787 }
8888
8989 Database = Database
@@ -110,62 +110,59 @@ def get_connection_params(self):
110110 settings_dict = self .settings_dict
111111
112112 conn_params = {
113- ' username' : None ,
114- ' password' : None ,
115- ' timeout' : 30 ,
113+ " username" : None ,
114+ " password" : None ,
115+ " timeout" : 30 ,
116116 }
117- if settings_dict [' USER' ]:
118- conn_params [' username' ] = settings_dict [' USER' ]
119- if settings_dict [' PASSWORD' ]:
120- conn_params [' password' ] = settings_dict [' PASSWORD' ]
121- if ' TIMEOUT' in settings_dict :
122- conn_params [' timeout' ] = settings_dict [' TIMEOUT' ]
123- if ' EMBEDDED' in settings_dict :
124- conn_params [' embedded' ] = settings_dict [' EMBEDDED' ]
125- if ' CONNECTION_STRING' in settings_dict :
126- conn_params [' connectionstr' ] = settings_dict [' CONNECTION_STRING' ]
117+ if settings_dict [" USER" ]:
118+ conn_params [" username" ] = settings_dict [" USER" ]
119+ if settings_dict [" PASSWORD" ]:
120+ conn_params [" password" ] = settings_dict [" PASSWORD" ]
121+ if " TIMEOUT" in settings_dict :
122+ conn_params [" timeout" ] = settings_dict [" TIMEOUT" ]
123+ if " EMBEDDED" in settings_dict :
124+ conn_params [" embedded" ] = settings_dict [" EMBEDDED" ]
125+ if " CONNECTION_STRING" in settings_dict :
126+ conn_params [" connectionstr" ] = settings_dict [" CONNECTION_STRING" ]
127127 else :
128128 conn_params = {
129- ' hostname' : ' localhost' ,
130- ' port' : 1972 ,
131- ' namespace' : ' USER' ,
129+ " hostname" : " localhost" ,
130+ " port" : 1972 ,
131+ " namespace" : " USER" ,
132132 ** conn_params ,
133133 }
134- if settings_dict [' HOST' ]:
135- conn_params [' hostname' ] = settings_dict [' HOST' ]
136- if settings_dict [' PORT' ]:
137- conn_params [' port' ] = settings_dict [' PORT' ]
138- if ' NAMESPACE' in settings_dict :
139- conn_params [' namespace' ] = settings_dict [' NAMESPACE' ]
140- if settings_dict [' NAME' ]:
141- conn_params [' namespace' ] = settings_dict [' NAME' ]
134+ if settings_dict [" HOST" ]:
135+ conn_params [" hostname" ] = settings_dict [" HOST" ]
136+ if settings_dict [" PORT" ]:
137+ conn_params [" port" ] = settings_dict [" PORT" ]
138+ if " NAMESPACE" in settings_dict :
139+ conn_params [" namespace" ] = settings_dict [" NAMESPACE" ]
140+ if settings_dict [" NAME" ]:
141+ conn_params [" namespace" ] = settings_dict [" NAME" ]
142142
143143 if (
144- not conn_params [' hostname' ] or
145- not conn_params [' port' ] or
146- not conn_params [' namespace' ]
144+ not conn_params [" hostname" ]
145+ or not conn_params [" port" ]
146+ or not conn_params [" namespace" ]
147147 ):
148148 raise ImproperlyConfigured (
149149 "settings.DATABASES is improperly configured. "
150150 "Please supply the HOST, PORT and NAME"
151151 )
152152
153- if (
154- not conn_params ['username' ] or
155- not conn_params ['password' ]
156- ):
153+ if not conn_params ["username" ] or not conn_params ["password" ]:
157154 raise ImproperlyConfigured (
158155 "settings.DATABASES is improperly configured. "
159156 "Please supply the USER and PASSWORD"
160157 )
161158
162- conn_params [' application_name' ] = ' django'
159+ conn_params [" application_name" ] = " django"
163160 conn_params ["autoCommit" ] = self .autocommit
164161 return conn_params
165162
166163 def init_connection_state (self ):
167164 pass
168-
165+
169166 @async_unsafe
170167 def get_new_connection (self , conn_params ):
171168 return Database .connect (** conn_params )
@@ -186,7 +183,7 @@ def create_cursor(self, name=None):
186183 def is_usable (self ):
187184 try :
188185 with self .connection .cursor () as cursor :
189- cursor .execute (' SELECT 1' )
186+ cursor .execute (" SELECT 1" )
190187 except :
191188 return False
192189 else :
0 commit comments