Skip to content

Commit 1263fc5

Browse files
authored
Merge pull request #58 from microsoft/dev
Prepare for 1.0 release
2 parents c0d1f88 + 5007a26 commit 1263fc5

File tree

9 files changed

+175
-62
lines changed

9 files changed

+175
-62
lines changed

README.md

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ We hope you enjoy using the MSSQL-Django 3rd party backend.
1010

1111
## Features
1212

13-
- Supports Django 2.2, 3.0 and 3.1
13+
- Supports Django 2.2, 3.0, 3.1 and 3.2
1414
- Tested on Microsoft SQL Server 2016, 2017, 2019
1515
- Passes most of the tests of the Django test suite
1616
- Compatible with
@@ -20,13 +20,11 @@ We hope you enjoy using the MSSQL-Django 3rd party backend.
2020

2121
## Dependencies
2222

23-
- Django 2.2, 3.0 or 3.1
2423
- pyodbc 3.0 or newer
2524

2625
## Installation
2726

28-
1. Install pyodbc 3.0 (or newer) and Django 2.2, 3.0 or 3.1
29-
27+
1. Install pyodbc 3.0 (or newer) and Django
3028
2. Install mssql-django:
3129

3230
pip install mssql-django
@@ -220,20 +218,27 @@ Here is an example of the database settings:
220218

221219
## Limitations
222220

223-
The following features are currently not supported:
224-
- mssql-django does not support SQL-based regex commands
225-
- Altering a model field from or to AutoField at migration
226-
227-
Certain limitations for JSONField lookups, more details [here](https://github.com/microsoft/mssql-django/wiki/JSONField).
228-
229-
## Future Plans
230-
231-
The following features and additions are planned:
232-
- install instructions for CLR .dll file to add SQL-based regex command support to SQL Server or Azure SQL DB
221+
The following features are currently not fully supported:
222+
- Altering a model field from or to AutoField at migration
223+
- Django annotate functions have floating point arithmetic problems in some cases
224+
- Annotate function with exists
225+
- Exists function in order_by
226+
- Righthand power and arithmetic with datatimes
227+
- Timezones, timedeltas not fully supported
228+
- `bulk_update` multiple field to null
229+
- Rename field/model with foreign key constraint
230+
- Database level constraints
231+
- Math degrees power or radians
232+
- Bit-shift operators
233+
- Filtered index
234+
- Date extract function
235+
- Hashing functions
236+
237+
JSONField lookups have limitations, more details [here](https://github.com/microsoft/mssql-django/wiki/JSONField).
233238

234239
## Contributing
235240

236-
More details on contributing can be found [Here](CONTRIBUTING.md).
241+
More details on contributing can be found [here](CONTRIBUTING.md).
237242

238243
This project welcomes contributions and suggestions. Most contributions require you to agree to a
239244
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us

azure-pipelines.yml

Lines changed: 96 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
trigger:
22
- master
33
- dev
4-
5-
variables:
6-
agent.preferPowerShellOnContainers: true
4+
- 1ES
75

86
schedules:
97
- cron: "0 9 * * *"
@@ -14,9 +12,98 @@ schedules:
1412
always: true
1513

1614
jobs:
15+
- job: Windows
16+
pool:
17+
name: Django-1ES-pool
18+
demands:
19+
- imageOverride -equals MMS2016
20+
timeoutInMinutes: 120
21+
22+
strategy:
23+
matrix:
24+
Python 3.9 - Django 3.2:
25+
python.version: '3.9'
26+
tox.env: 'py39-django32'
27+
Python 3.8 - Django 3.2:
28+
python.version: '3.8'
29+
tox.env: 'py38-django32'
30+
Python 3.7 - Django 3.2:
31+
python.version: '3.7'
32+
tox.env: 'py37-django32'
33+
Python 3.6 - Django 3.2:
34+
python.version: '3.6'
35+
tox.env: 'py36-django32'
36+
37+
Python 3.9 - Django 3.1:
38+
python.version: '3.9'
39+
tox.env: 'py39-django31'
40+
Python 3.8 - Django 3.1:
41+
python.version: '3.8'
42+
tox.env: 'py38-django31'
43+
Python 3.7 - Django 3.1:
44+
python.version: '3.7'
45+
tox.env: 'py37-django31'
46+
Python 3.6 - Django 3.1:
47+
python.version: '3.6'
48+
tox.env: 'py36-django31'
49+
50+
Python 3.9 - Django 3.0:
51+
python.version: '3.9'
52+
tox.env: 'py39-django30'
53+
Python 3.8 - Django 3.0:
54+
python.version: '3.8'
55+
tox.env: 'py38-django30'
56+
Python 3.7 - Django 3.0:
57+
python.version: '3.7'
58+
tox.env: 'py37-django30'
59+
Python 3.6 - Django 3.0:
60+
python.version: '3.6'
61+
tox.env: 'py36-django30'
62+
63+
Python 3.7 - Django 2.2:
64+
python.version: '3.7'
65+
tox.env: 'py37-django22'
66+
Python 3.6 - Django 2.2:
67+
python.version: '3.6'
68+
tox.env: 'py36-django22'
69+
70+
steps:
71+
- task: CredScan@2
72+
inputs:
73+
toolMajorVersion: 'V2'
74+
75+
- task: UsePythonVersion@0
76+
inputs:
77+
versionSpec: "$(python.version)"
78+
displayName: Use Python $(python.version)
79+
80+
- powershell: |
81+
$IP=Get-NetIPAddress -AddressFamily IPv4 -InterfaceIndex $(Get-NetConnectionProfile -IPv4Connectivity Internet | Select-Object -ExpandProperty InterfaceIndex) | Select-Object -ExpandProperty IPAddress
82+
83+
(Get-Content $pwd/testapp/settings.py).replace('localhost', $IP) | Set-Content $pwd/testapp/settings.py
84+
85+
Invoke-WebRequest https://download.microsoft.com/download/E/6/B/E6BFDC7A-5BCD-4C51-9912-635646DA801E/en-US/17.5.2.1/x64/msodbcsql.msi -OutFile msodbcsql.msi
86+
msiexec /quiet /passive /qn /i msodbcsql.msi IACCEPTMSODBCSQLLICENSETERMS=YES
87+
Get-OdbcDriver
88+
89+
docker pull microsoft/mssql-server-windows-developer
90+
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPassword42' -p 1433:1433 -d microsoft/mssql-server-windows-developer
91+
docker ps
92+
93+
- powershell: |
94+
python -m pip install --upgrade pip wheel setuptools
95+
python -m pip install tox
96+
git clone https://github.com/django/django.git
97+
98+
python -m tox -e $(tox.env)
99+
displayName: Run tox
100+
17101
- job: Linux
18102
pool:
19-
vmImage: ubuntu-18.04
103+
name: Django-1ES-pool
104+
demands:
105+
- imageOverride -equals MMSUbuntu20.04
106+
timeoutInMinutes: 120
20107

21108
strategy:
22109
matrix:
@@ -73,10 +160,10 @@ jobs:
73160
displayName: Use Python $(python.version)
74161

75162
- script: |
76-
docker pull mcr.microsoft.com/mssql/server:2017-latest-ubuntu
77-
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPassword42' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2017-latest-ubuntu
163+
docker pull mcr.microsoft.com/mssql/server:2019-latest
164+
docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=MyPassword42' -p 1433:1433 -d mcr.microsoft.com/mssql/server:2019-latest
78165
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
79-
curl https://packages.microsoft.com/config/ubuntu/18.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
166+
curl https://packages.microsoft.com/config/ubuntu/20.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
80167
sudo apt-get update
81168
sudo ACCEPT_EULA=Y apt-get install -y msodbcsql17 g++ unixodbc-dev libmemcached-dev
82169
displayName: Install SQL Server
@@ -93,11 +180,11 @@ jobs:
93180
- task: PublishCodeCoverageResults@1
94181
inputs:
95182
codeCoverageTool: 'Cobertura'
96-
summaryFileLocation: '/home/vsts/coverage.xml'
183+
summaryFileLocation: 'django/coverage.xml'
97184

98185
- task: PublishTestResults@2
99186
displayName: Publish test results via jUnit
100187
inputs:
101188
testResultsFormat: 'JUnit'
102-
testResultsFiles: '/home/vsts/result.xml'
189+
testResultsFiles: 'result.xml'
103190
testRunTitle: 'junit-$(Agent.OS)-$(Agent.OSArchitecture)-$(tox.env)'

mssql/client.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,24 @@
1010
class DatabaseClient(BaseDatabaseClient):
1111
executable_name = 'sqlcmd'
1212

13-
def runshell(self):
14-
settings_dict = self.connection.settings_dict
13+
@classmethod
14+
def settings_to_cmd_args(cls, settings_dict, parameters):
1515
options = settings_dict['OPTIONS']
1616
user = options.get('user', settings_dict['USER'])
1717
password = options.get('passwd', settings_dict['PASSWORD'])
1818

1919
driver = options.get('driver', 'ODBC Driver 13 for SQL Server')
2020
ms_drivers = re.compile('^ODBC Driver .* for SQL Server$|^SQL Server Native Client')
2121
if not ms_drivers.match(driver):
22-
self.executable_name = 'isql'
22+
cls.executable_name = 'isql'
2323

24-
if self.executable_name == 'sqlcmd':
24+
if cls.executable_name == 'sqlcmd':
2525
db = options.get('db', settings_dict['NAME'])
2626
server = options.get('host', settings_dict['HOST'])
2727
port = options.get('port', settings_dict['PORT'])
2828
defaults_file = options.get('read_default_file')
2929

30-
args = [self.executable_name]
30+
args = [cls.executable_name]
3131
if server:
3232
if port:
3333
server = ','.join((server, str(port)))
@@ -44,9 +44,11 @@ def runshell(self):
4444
args += ["-i", defaults_file]
4545
else:
4646
dsn = options.get('dsn', '')
47-
args = ['%s -v %s %s %s' % (self.executable_name, dsn, user, password)]
47+
args = ['%s -v %s %s %s' % (cls.executable_name, dsn, user, password)]
4848

49-
try:
50-
subprocess.check_call(args)
51-
except KeyboardInterrupt:
52-
pass
49+
args.extend(parameters)
50+
return args
51+
52+
def runshell(self, parameters=[]):
53+
args = DatabaseClient.settings_to_cmd_args(self.connection.settings_dict, parameters)
54+
subprocess.run(args, check=True)

mssql/creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def install_regex_clr(self, database_name):
9696

9797
self.enable_clr()
9898

99-
with self.self.cursor() as cursor:
99+
with self.cursor() as cursor:
100100
for s in sql:
101101
cursor.execute(s)
102102

mssql/features.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class DatabaseFeatures(BaseDatabaseFeatures):
2929
requires_literal_defaults = True
3030
requires_sqlparse_for_splitting = False
3131
supports_boolean_expr_in_select_clause = False
32+
supports_covering_indexes = True
3233
supports_deferrable_unique_constraints = False
3334
supports_expression_indexes = False
3435
supports_ignore_conflicts = False

0 commit comments

Comments
 (0)