-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support LinkML field names with spaces. #75
Changes from all commits
dd7d83f
6dc15ee
7374ca9
e14a0c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,7 +62,7 @@ from support.enums import | |
{%- endfor %} | ||
|
||
|
||
E = typing.TypeVar("E", base_db.File, base_db.Entity) | ||
E = typing.TypeVar("E", base_db.File, db.{{ cls.name }}) | ||
T = typing.TypeVar("T") | ||
|
||
if TYPE_CHECKING: | ||
|
@@ -507,7 +507,7 @@ async def create_{{ cls.snake_name }}( | |
cerbos_client: CerbosClient = Depends(get_cerbos_client), | ||
principal: Principal = Depends(require_auth_principal), | ||
is_system_user: bool = Depends(is_system_user), | ||
) -> db.Entity: | ||
) -> db.{{ cls.name }}: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These return the current type, there's no reason to tell the type checker that we return the base type. I think. 😅 |
||
""" | ||
Create a new {{ cls.name }} object. Used for mutations (see api/mutations.py). | ||
""" | ||
|
@@ -567,7 +567,7 @@ async def update_{{ cls.snake_name }}( | |
cerbos_client: CerbosClient = Depends(get_cerbos_client), | ||
principal: Principal = Depends(require_auth_principal), | ||
is_system_user: bool = Depends(is_system_user), | ||
) -> Sequence[db.Entity]: | ||
) -> Sequence[db.{{ cls.name }}]: | ||
""" | ||
Update {{ cls.name }} objects. Used for mutations (see api/mutations.py). | ||
""" | ||
|
@@ -640,7 +640,7 @@ async def delete_{{ cls.snake_name }}( | |
session: AsyncSession = Depends(get_db_session, use_cache=False), | ||
cerbos_client: CerbosClient = Depends(get_cerbos_client), | ||
principal: Principal = Depends(require_auth_principal), | ||
) -> Sequence[db.Entity]: | ||
) -> Sequence[db.{{ cls.name }}]: | ||
""" | ||
Delete {{ cls.name }} objects. Used for mutations (see api/mutations.py). | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -293,6 +293,8 @@ classes: | |
annotations: | ||
minimum_length: 3 | ||
maximum_length: 8 | ||
field with spaces: | ||
range: string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An example of a field with spaces in its name! |
||
regex_format_check: | ||
range: string | ||
pattern: '\d{3}-\d{2}-\d{4}' | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
""" | ||
Test basic queries and mutations | ||
""" | ||
|
||
import datetime | ||
import pytest | ||
from platformics.database.connect import SyncDB | ||
from conftest import GQLTestClient, SessionStorage | ||
from test_infra.factories.constraint_checked_type import ConstraintCheckedTypeFactory | ||
|
||
date_now = datetime.datetime.now() | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_field_with_spaces( | ||
sync_db: SyncDB, | ||
gql_client: GQLTestClient, | ||
) -> None: | ||
""" | ||
Test that we can only fetch samples from the database that we have access to | ||
""" | ||
user_id = 12345 | ||
project_id = 123 | ||
|
||
# Create mock data | ||
with sync_db.session() as session: | ||
SessionStorage.set_session(session) | ||
cct = ConstraintCheckedTypeFactory.create( | ||
owner_user_id=user_id, | ||
collection_id=project_id, | ||
) | ||
|
||
# Fetch the row via gql | ||
query = """ | ||
query MyQuery { | ||
constraintCheckedTypes { | ||
id, | ||
fieldWithSpaces | ||
} | ||
} | ||
""" | ||
output = await gql_client.query(query, user_id=user_id, member_projects=[project_id]) | ||
assert cct.field_with_spaces == output["data"]["constraintCheckedTypes"][0]["fieldWithSpaces"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check that this field is wired up properly from the test infrastructure all the way to the GQL interface! |
||
assert output["data"]["constraintCheckedTypes"][0]["fieldWithSpaces"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just making the error messages a little more verbose / easier to debug.