Skip to content

Commit 9c56945

Browse files
Merge branch 'master' into keysource
2 parents 69174c5 + 7b43a51 commit 9c56945

File tree

9 files changed

+23
-7
lines changed

9 files changed

+23
-7
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## Release notes
22

33
### 0.13.3 -- TBD
4+
* Bugfix - Fix Python 3.10 compatibility (#983) PR #972
5+
* Bugfix - Allow renaming non-conforming attributes in proj (#982) PR #972
46
* Add - Expose proxy feature for S3 external stores (#961) PR #962
57
* Bugfix - Dependencies not properly loaded on populate. (#902) PR #919
68
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939

LNX-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
interval: 1s
3333
fakeservices.datajoint.io:
3434
<<: *net
35-
image: datajoint/nginx:v0.0.18
35+
image: datajoint/nginx:v0.0.19
3636
environment:
3737
- ADD_db_TYPE=DATABASE
3838
- ADD_db_ENDPOINT=db:3306

datajoint/declare.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
UUID_DATA_TYPE = 'binary(16)'
1313
MAX_TABLE_NAME_LENGTH = 64
14-
CONSTANT_LITERALS = {'CURRENT_TIMESTAMP'} # SQL literals to be used without quotes (case insensitive)
14+
CONSTANT_LITERALS = {'CURRENT_TIMESTAMP', 'NULL'} # SQL literals to be used without quotes (case insensitive)
1515
EXTERNAL_TABLE_ROOT = '~external'
1616

1717
TYPE_PATTERN = {k: re.compile(v, re.I) for k, v in dict(

datajoint/expression.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from .preview import preview, repr_html
1010
from .condition import AndList, Not, \
1111
make_condition, assert_join_compatibility, extract_column_names, PromiscuousOperand
12+
from .declare import CONSTANT_LITERALS
1213

1314
logger = logging.getLogger(__name__)
1415

@@ -313,9 +314,9 @@ def proj(self, *attributes, **named_attributes):
313314
Each attribute name can only be used once.
314315
"""
315316
# new attributes in parentheses are included again with the new name without removing original
316-
duplication_pattern = re.compile(r'\s*\(\s*(?P<name>\w+)\s*\)\s*$')
317+
duplication_pattern = re.compile(fr'^\s*\(\s*(?!{"|".join(CONSTANT_LITERALS)})(?P<name>[a-zA-Z_]\w*)\s*\)\s*$')
317318
# attributes without parentheses renamed
318-
rename_pattern = re.compile(r'\s*(?P<name>\w+)\s*$')
319+
rename_pattern = re.compile(fr'^\s*(?!{"|".join(CONSTANT_LITERALS)})(?P<name>[a-zA-Z_]\w*)\s*$')
319320
replicate_map = {k: m.group('name')
320321
for k, m in ((k, duplication_pattern.match(v)) for k, v in named_attributes.items()) if m}
321322
rename_map = {k: m.group('name')

datajoint/external.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from pathlib import Path, PurePosixPath, PureWindowsPath
2-
from collections import Mapping
2+
from collections.abc import Mapping
33
from tqdm import tqdm
44
from .settings import config
55
from .errors import DataJointError, MissingExternalFile

datajoint/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
}
5959

6060

61-
class Config(collections.MutableMapping):
61+
class Config(collections.abc.MutableMapping):
6262

6363
instance = None
6464

docs-parts/intro/Releases_lang1.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
0.13.3 -- TBD
22
----------------------
3+
* Bugfix - Fix Python 3.10 compatibility (#983) PR #972
4+
* Bugfix - Allow renaming non-conforming attributes in proj (#982) PR #972
35
* Add - Expose proxy feature for S3 external stores (#961) PR #962
46
* Bugfix - Dependencies not properly loaded on populate. (#902) PR #919
57
* Bugfix - Replace use of numpy aliases of built-in types with built-in type. (#938) PR #939

local-docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ services:
3434
interval: 1s
3535
fakeservices.datajoint.io:
3636
<<: *net
37-
image: datajoint/nginx:v0.0.18
37+
image: datajoint/nginx:v0.0.19
3838
environment:
3939
- ADD_db_TYPE=DATABASE
4040
- ADD_db_ENDPOINT=db:3306

tests/test_relational_operand.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from .schema import (Experiment, TTest3, Trial, Ephys, Child, Parent, SubjectA, SessionA,
1414
SessionStatusA, SessionDateA)
1515

16+
from . import PREFIX, CONN_INFO
17+
1618

1719
def setup():
1820
"""
@@ -177,6 +179,15 @@ def test_project():
177179
assert_equal(len((D() & cond).proj()), len((D() & cond)),
178180
'projection failed: altered its argument''s cardinality')
179181

182+
@staticmethod
183+
def test_rename_non_dj_attribute():
184+
schema = PREFIX + '_test1'
185+
connection = dj.conn(**CONN_INFO)
186+
connection.query(f'CREATE TABLE {schema}.test_table (oldID int PRIMARY KEY)').fetchall()
187+
mySchema = dj.VirtualModule(schema, schema)
188+
assert 'oldID' not in mySchema.TestTable.proj(new_name='oldID').heading.attributes.keys(), 'Failed to rename attribute correctly'
189+
connection.query(f'DROP TABLE {schema}.test_table')
190+
180191
@staticmethod
181192
def test_union():
182193
x = set(zip(*IJ.fetch('i', 'j')))

0 commit comments

Comments
 (0)