Skip to content

Commit 6c6225e

Browse files
fantixarunaruljothi
andcommitted
Use name hint when server is not providing custom scalar type name (#461)
Co-authored-by: Arun Aruljothi <arun@arunaruljothi.com>
1 parent 758a391 commit 6c6225e

10 files changed

+565
-3
lines changed

.github/workflows/tests.yml

+4
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ jobs:
8686
if: steps.release.outputs.version == 0
8787
env:
8888
LOOP_IMPL: ${{ matrix.loop }}
89+
SERVER_VERSION: ${{ matrix.edgedb-version }}
8990
run: |
91+
if [ "${SERVER_VERSION}" = "nightly" ]; then
92+
export EDGEDB_TEST_CODEGEN_ASSERT_SUFFIX=.assert4
93+
fi
9094
if [ "${LOOP_IMPL}" = "uvloop" ]; then
9195
env USE_UVLOOP=1 python -m unittest -v tests.suite
9296
else

edgedb/codegen/generator.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ def _generate_code(
452452
rv = f"typing.Tuple[{elements}]"
453453

454454
elif isinstance(type_, describe.ScalarType):
455-
rv = self._find_name(type_.name)
455+
rv = self._find_name(type_.name or name_hint)
456456
base_type_name = type_.base_type.name
457457
if import_str := imports.get(base_type_name):
458458
self._imports.add(import_str)

tests/codegen/test-project2/generated_async_edgeql.py.assert

+15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# AUTOGENERATED FROM:
2+
# 'scalar/custom_vector_input.edgeql'
23
# 'object/link_prop.edgeql'
34
# 'parpkg/subpkg/my_query.edgeql'
45
# 'argnames/query_one.edgeql'
@@ -21,6 +22,7 @@ import typing
2122
import uuid
2223

2324

25+
Input = typing.Sequence[float]
2426
MyScalar = int
2527

2628

@@ -140,6 +142,19 @@ class SelectObjectResultParamsItem:
140142
Default: str | None
141143

142144

145+
async def custom_vector_input(
146+
executor: edgedb.AsyncIOExecutor,
147+
*,
148+
input: Input | None,
149+
) -> int | None:
150+
return await executor.query_single(
151+
"""\
152+
select 42 filter exists <optional v3>$input;\
153+
""",
154+
input=input,
155+
)
156+
157+
143158
async def link_prop(
144159
executor: edgedb.AsyncIOExecutor,
145160
) -> list[LinkPropResult]:

0 commit comments

Comments
 (0)