Skip to content

fix: can't query vertex with number vertex id#329

Open
neoblackcap wants to merge 1 commit into
apache:mainfrom
neoblackcap:fix/number_type_vertex_id
Open

fix: can't query vertex with number vertex id#329
neoblackcap wants to merge 1 commit into
apache:mainfrom
neoblackcap:fix/number_type_vertex_id

Conversation

@neoblackcap
Copy link
Copy Markdown

  1. make vertex api compactible with number type vertex id
  2. add test case for add/append/eliminate/remove vertex with number type vertex id

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label May 11, 2026
@neoblackcap neoblackcap force-pushed the fix/number_type_vertex_id branch 2 times, most recently from 067b00d to bc2719d Compare May 11, 2026 10:47
1. make vertex api compactible with number type vertex id
2. add test case for add/append/eliminate/remove vertex with number type vertex id
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the HugeGraph Python client’s vertex APIs to support querying/operating on vertices whose IDs are numeric (not only string IDs), and adds regression tests around these vertex operations.

Changes:

  • Adjusted vertex REST routes to remove always-on quoting around {vertex_id}, and added router-side formatting logic intended to quote only string vertex IDs.
  • Added schema/test coverage for a new department vertex label used to exercise numeric vertex-id behavior.
  • Tweaked getVerticesById() query construction to JSON-quote ids (strings quoted, numbers not).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
hugegraph-python-client/src/tests/client_utils.py Adds new property keys and a department vertex label for numeric-id tests.
hugegraph-python-client/src/tests/api/test_graph.py Adds new test cases covering append/eliminate/get/remove for numeric vertex IDs.
hugegraph-python-client/src/pyhugegraph/utils/huge_router.py Adds special vertex_id formatting logic in the route formatter.
hugegraph-python-client/src/pyhugegraph/api/graph.py Updates vertex endpoints to use unquoted {vertex_id} and adjusts getVerticesById() id quoting.
hugegraph-python-client/pyproject.toml Minor dependency formatting adjustment.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +152 to +158
elif "{vertex_id}" in path:
# fix vertex_id format process
# only quote string type vertex_id
vertex_id = all_kwargs.pop("vertex_id")
if isinstance(vertex_id, str):
vertex_id = "\"" + vertex_id + "\""
all_kwargs['vertex_id'] = vertex_id

import functools
import inspect
import json
schema.vertexLabel("book").useCustomizeStringId().properties("name", "price").nullableKeys(
"price"
).ifNotExist().create()
schema.vertexLabel("department").properties("name", "headcount", "floor").nullableKeys(
self.graph.getVertexById(vertex.id)
except NotFoundError as e:
msg = "\\'{}\\' does not exist".format(vertex.id)
logger.info(f'test_msg: {msg}')
Comment on lines +111 to +118
self.graph.removeVertexById(vertex.id)
try:
self.graph.getVertexById(vertex.id)
except NotFoundError as e:
msg = "\\'{}\\' does not exist".format(vertex.id)
logger.info(f'test_msg: {msg}')
self.assertTrue(msg in str(e))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python-client size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants