Skip to content
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

Fix additional properties bug #379

Merged
merged 2 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions test/gql/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,40 @@
@pytest.mark.parametrize(
"props,expected",
[
(AdditionalProperties(uuid=True), "_additional{id}"),
(AdditionalProperties(uuid=True), " _additional{id} "),
(
AdditionalProperties(uuid=True, vector=True, explainScore=True),
"_additional{id vector explainScore}",
" _additional{id vector explainScore} ",
),
(
AdditionalProperties(uuid=False, vector=True, explainScore=True, score=True),
"_additional{vector score explainScore}",
" _additional{vector score explainScore} ",
),
],
)
def test_additional_props(props: AdditionalProperties, expected: str):
assert str(props) == expected


@pytest.mark.parametrize(
"additional_props,expected",
[
(AdditionalProperties(uuid=True), " _additional{id} "),
],
)
def test_getbuilder_with_additional_props(additional_props: AdditionalProperties, expected: str):
query = (
GetBuilder("TestClass", "name", mock_connection_v117)
.with_additional(additional_props)
.build()
)
expected_query = "{Get{TestClass{name" + expected + "}}}"
assert (
"name_" not in expected_query
) # Check that the prop name is not being concatnated to _additional
assert query == expected_query


@pytest.mark.parametrize(
"query,properties,expected",
[
Expand Down
2 changes: 1 addition & 1 deletion weaviate/gql/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def __str__(self) -> str:
name = "id"
additional_props.append(name)
if len(additional_props) > 0:
return "_additional{" + " ".join(additional_props) + "}"
return " _additional{" + " ".join(additional_props) + "} "
else:
return ""

Expand Down