Skip to content

Commit 8afc4d1

Browse files
Merge pull request #63 from Synicix/master
Change list table to use virutal module instaed of schema
2 parents 0f3b641 + 044714b commit 8afc4d1

File tree

5 files changed

+35
-16
lines changed

5 files changed

+35
-16
lines changed

CHANGELOG.md

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

33
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.
44

5+
## [Unreleased]
6+
7+
### Fixed
8+
- Fixed behavior where using list_table with a nonexistent schema_name creates it instead of returning an error message (#65) PR #63
9+
510
## [0.1.0b0] - 2021-02-26
611

712
### Security
@@ -36,5 +41,6 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
3641
- Support for DataJoint attribute types: `varchar`, `int`, `float`, `datetime`, `date`, `time`, `decimal`, `uuid`.
3742
- Check dependency utility to determine child table references.
3843

44+
[Unreleased]: https://github.com/datajoint/pharus/compare/0.1.0b0...HEAD
3945
[0.1.0b0]: https://github.com/datajoint/pharus/compare/0.1.0a5...0.1.0b0
4046
[0.1.0a5]: https://github.com/datajoint/pharus/releases/tag/0.1.0a5

pharus/interface.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def list_tables(jwt_payload: dict, schema_name: str):
6969
"""
7070
DJConnector.set_datajoint_config(jwt_payload)
7171

72-
# Get list of tables names\
73-
tables_name = dj.schema(schema_name).list_tables()
72+
# Get list of tables names
73+
tables_name = dj.Schema(schema_name, create_schema=False).list_tables()
7474

7575
# Dict to store list of table name for each type
7676
tables_dict_list = dict(manual_tables=[], lookup_tables=[], computed_tables=[],
@@ -112,7 +112,7 @@ def fetch_tuples(jwt_payload: dict, schema_name: str, table_name: str,
112112
:type schema_name: str
113113
:param table_name: Table name under the given schema; must be in camel case
114114
:type table_name: str
115-
:param restriction: Sequence of filter cards with attribute_name, operation, value
115+
:param restriction: Sequence of filter cards with attributeName, operation, value
116116
defined, defaults to []
117117
:type restriction: list, optional
118118
:param limit: Max number of records to return, defaults to 1000

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
flask
22
gunicorn
33
pyjwt[crypto]
4-
datajoint==0.13.dev4
4+
datajoint==0.13.dev5
55
datajoint_connection_hub

tests/test_list_tables.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from . import client, connection, token, schema_main, ParentPart
2+
from flask.wrappers import Response
3+
import datajoint as dj
4+
5+
def test_list_tables(token, client, ParentPart):
6+
ScanData, ProcessScanData = ParentPart
7+
REST_tables = client.post(
8+
'/list_tables',
9+
headers=dict(Authorization=f'Bearer {token}'),
10+
json=dict(schemaName=ScanData.database)).json['tableTypeAndNames']
11+
assert ScanData.__name__ == REST_tables['manual_tables'][0]
12+
assert ProcessScanData.__name__ == REST_tables['computed_tables'][0]
13+
assert f"""{ProcessScanData.__name__}.{
14+
ProcessScanData.ProcessScanDataPart.__name__}""" == REST_tables['part_tables'][0]
15+
16+
def test_invalid_schema_list_table(token, client, schema_main):
17+
# Test invalid schema
18+
response: Response = client.post(
19+
'/list_tables',
20+
headers=dict(Authorization=f'Bearer {token}'),
21+
json=dict(schemaName='invalid_schema')
22+
)
23+
24+
assert(response.status_code != 200)
25+
assert('invalid_schema' not in dj.list_schemas())

tests/test_schemas.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,3 @@ def test_schemas(token, client, connection, schemas_simple):
1010
assert set(REST_schemas) == set(
1111
[s for s in dj.list_schemas(connection=connection)
1212
if s not in ('mysql', 'performance_schema', 'sys')])
13-
14-
15-
def test_tables(token, client, ParentPart):
16-
ScanData, ProcessScanData = ParentPart
17-
REST_tables = client.post(
18-
'/list_tables',
19-
headers=dict(Authorization=f'Bearer {token}'),
20-
json=dict(schemaName=ScanData.database)).json['tableTypeAndNames']
21-
assert ScanData.__name__ == REST_tables['manual_tables'][0]
22-
assert ProcessScanData.__name__ == REST_tables['computed_tables'][0]
23-
assert f"""{ProcessScanData.__name__}.{
24-
ProcessScanData.ProcessScanDataPart.__name__}""" == REST_tables['part_tables'][0]

0 commit comments

Comments
 (0)