Skip to content

Commit 07dc0ee

Browse files
Merge pull request #131 from A-Baji/multi-table-insert
Allow schema templating for insert queries using query params
2 parents dafb069 + b4d37cb commit 07dc0ee

File tree

5 files changed

+13
-7
lines changed

5 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
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+
## [0.5.1] - 2022-09-27
6+
### Added
7+
- Schema templating for insert queries using query params PR #131
8+
59
## [0.5.0] - 2022-09-21
610
### Fixed
711
- Bugs with returning UUID and NaN values PR #128

pharus/component_interface.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ def __init__(
156156
),
157157
t,
158158
)
159-
for s, t in (_.split(".") for _ in component_config["tables"])
159+
for s, t in (
160+
_.format(**request.args).split(".") for _ in component_config["tables"]
161+
)
160162
]
161163
self.parents = sorted(
162164
set(

pharus/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
"""Package metadata."""
2-
__version__ = "0.5.0"
2+
__version__ = "0.5.1"

tests/init/test_dynamic_api_spec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ SciViz: # top level tab
7777
width: 1
7878
type: form
7979
tables:
80-
- test_group1_simple.TableB
81-
- test_group1_simple.TableC
80+
- "{group}_simple.TableB"
81+
- "{group}_simple.TableC"
8282
insert4:
8383
route: /insert4
8484
x: 1

tests/test_form.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def test_insert_map(token, client, connection, schemas_simple):
2424

2525
def test_insert_no_map(token, client, connection, schemas_simple):
2626
REST_response = client.post(
27-
"/insert3",
27+
"/insert3?group=test_group1",
2828
json={
2929
"submissions": [
3030
{"a_id": 1, "b_id": 32, "b_number": 1.23, "c_id": 400, "c_int": 99}
@@ -38,7 +38,7 @@ def test_insert_no_map(token, client, connection, schemas_simple):
3838

3939
def test_insert_fail(token, client, connection, schemas_simple):
4040
REST_response = client.post(
41-
"/insert3",
41+
"/insert3?group=test_group1",
4242
json={"submissions": [{"a_id": 1, "b_id": 32, "b_number": 1.23, "c_id": 400}]},
4343
headers=dict(Authorization=f"Bearer {token}"),
4444
)
@@ -85,7 +85,7 @@ def test_form_response_no_table_map(token, client, connection, schemas_simple):
8585

8686
def test_form_response_no_map(token, client, connection, schemas_simple):
8787
REST_response = client.get(
88-
"/insert3/fields",
88+
"/insert3/fields?group=test_group1",
8989
headers=dict(Authorization=f"Bearer {token}"),
9090
)
9191
assert REST_response.status_code == 200, f"Error: {REST_response.data}"

0 commit comments

Comments
 (0)