Skip to content

Commit e482930

Browse files
committed
some fixes
1 parent c683b04 commit e482930

File tree

8 files changed

+136
-76
lines changed

8 files changed

+136
-76
lines changed

.gitignore

Lines changed: 101 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,101 @@
1-
__pycache__
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# Distribution / packaging
7+
.Python
8+
build/
9+
develop-eggs/
10+
dist/
11+
downloads/
12+
eggs/
13+
.eggs/
14+
lib/
15+
lib64/
16+
parts/
17+
sdist/
18+
var/
19+
wheels/
20+
*.egg-info/
21+
.installed.cfg
22+
*.egg
23+
MANIFEST
24+
25+
# PyInstaller
26+
# Usually these files are written by a python script from a template
27+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
28+
*.manifest
29+
*.spec
30+
31+
# Installer logs
32+
pip-log.txt
33+
pip-delete-this-directory.txt
34+
35+
# Unit test / coverage reports
36+
htmlcov/
37+
.tox/
38+
.coverage
39+
.coverage.*
40+
.cache
41+
nosetests.xml
42+
coverage.xml
43+
*.cover
44+
.hypothesis/
45+
.pytest_cache/
46+
47+
# Translations
48+
*.mo
49+
*.pot
50+
51+
# Django stuff:
52+
*.log
53+
local_settings.py
54+
db.sqlite3
55+
56+
# Flask stuff:
57+
instance/
58+
.webassets-cache
59+
60+
# Scrapy stuff:
61+
.scrapy
62+
63+
# Sphinx documentation
64+
docs/_build/
65+
66+
# PyBuilder
67+
target/
68+
69+
# Jupyter Notebook
70+
.ipynb_checkpoints
71+
72+
# pyenv
73+
.python-version
74+
75+
# celery beat schedule file
76+
celerybeat-schedule
77+
78+
# SageMath parsed files
79+
*.sage.py
80+
81+
# Environments
82+
.env
83+
.venv
84+
env/
85+
venv/
86+
ENV/
87+
env.bak/
88+
venv.bak/
89+
90+
# Spyder project settings
91+
.spyderproject
92+
.spyproject
93+
94+
# Rope project settings
95+
.ropeproject
96+
97+
# mkdocs documentation
98+
/site
99+
100+
# mypy
101+
.mypy_cache/

django_iris/base.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@
33
from django.db.backends.base.creation import BaseDatabaseCreation
44
from django.core.exceptions import ImproperlyConfigured
55
from django.utils.asyncio import async_unsafe
6-
from django.utils.functional import cached_property
76

87
from .introspection import DatabaseIntrospection
98
from .features import DatabaseFeatures
109
from .schema import DatabaseSchemaEditor
1110
from .operations import DatabaseOperations
1211
from .cursor import CursorWrapper
13-
14-
from django.db import DataError
12+
from .creation import DatabaseCreation
13+
from .validation import DatabaseValidation
1514

1615
import iris as Database
17-
import traceback
1816

1917

2018
Database.Warning = type("StandardError", (object,), {})
@@ -39,11 +37,6 @@ class DatabaseClient(BaseDatabaseClient):
3937
runshell = ignore
4038

4139

42-
class DatabaseCreation(BaseDatabaseCreation):
43-
create_test_db = ignore
44-
destroy_test_db = ignore
45-
46-
4740
class DatabaseWrapper(BaseDatabaseWrapper):
4841
vendor = 'interystems'
4942
display_name = 'InterSystems IRIS'
@@ -65,7 +58,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
6558
'BigIntegerField': 'BIGINT',
6659
'IPAddressField': 'CHAR(15)',
6760
'GenericIPAddressField': 'CHAR(39)',
68-
'JSONField': 'json',
61+
'JSONField': 'VARCHAR(32768)',
6962
'OneToOneField': 'INTEGER',
7063
'PositiveBigIntegerField': 'BIGINT',
7164
'PositiveIntegerField': 'INTEGER',
@@ -114,6 +107,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
114107
features_class = DatabaseFeatures
115108
introspection_class = DatabaseIntrospection
116109
ops_class = DatabaseOperations
110+
validation_class = DatabaseValidation
117111

118112
def get_connection_params(self):
119113
settings_dict = self.settings_dict
@@ -169,7 +163,7 @@ def get_new_connection(self, conn_params):
169163
return Database.connect(**conn_params)
170164

171165
def init_connection_state(self):
172-
assignments = []
166+
pass
173167

174168
@async_unsafe
175169
def create_cursor(self, name=None):

django_iris/creation.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.db.backends.base.creation import BaseDatabaseCreation
2+
3+
4+
class DatabaseCreation(BaseDatabaseCreation):
5+
6+
def _execute_create_test_db(self, cursor, parameters, keepdb=False):
7+
pass

django_iris/features.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ class DatabaseFeatures(BaseDatabaseFeatures):
77
has_bulk_insert = False
88
has_native_uuid_field = False
99
supports_timezones = False
10-
uses_savepoints = False
1110
can_clone_databases = False
1211
test_db_allows_multiple_connections = False
1312
supports_unspecified_pk = False
1413
can_return_columns_from_insert = False
14+
15+
supports_column_check_constraints = False
16+
supports_table_check_constraints = False
17+
can_introspect_check_constraints = False

django_iris/iris.py

Lines changed: 0 additions & 61 deletions
This file was deleted.

django_iris/operations.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
class DatabaseOperations(BaseDatabaseOperations):
88
def quote_name(self, name):
9-
return name
9+
if name.startswith('"') and name.endswith('"'):
10+
return name # Quoting once is enough.
11+
return '"%s"' % name
1012

1113
def adapt_datetimefield_value(self, value):
1214
if value is None:

django_iris/schema.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from decimal import Decimal
22

33
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
4-
4+
from django.db import NotSupportedError
55

66
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
77
sql_alter_column_type = "ALTER COLUMN %(column)s %(type)s"
@@ -20,3 +20,10 @@ def quote_value(self, value):
2020

2121
def prepare_default(self, value):
2222
raise NotImplementedError()
23+
24+
def table_sql(self, model):
25+
if '.' in model._meta.db_table:
26+
raise NotSupportedError(
27+
"Invalid table name '%s'" % (model._meta.db_table)
28+
)
29+
return super().table_sql(model)

django_iris/validation.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.db.backends.base.validation import BaseDatabaseValidation
2+
3+
class DatabaseValidation(BaseDatabaseValidation):
4+
def check(self, **kwargs):
5+
return []
6+
7+
def check_field(self, field, **kwargs):
8+
return []

0 commit comments

Comments
 (0)