From 20020f2d96355ea45799190545409aaa4cda9ca2 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Wed, 2 Nov 2022 16:53:17 -0400 Subject: [PATCH] Use Executor on generated code for Client/Tx --- edgedb/codegen/generator.py | 8 ++--- .../linked/test_linked_async_edgeql.py.assert | 4 +-- .../linked/test_linked_edgeql.py.assert | 4 +-- .../generated_async_edgeql.py.assert | 12 +++---- ...elect_optional_json_async_edgeql.py.assert | 4 +-- .../select_optional_json_edgeql.py.assert | 4 +-- .../select_scalar_async_edgeql.py.assert | 4 +-- .../select_scalar_edgeql.py.assert | 4 +-- .../argnames/query_one_async_edgeql.py.assert | 4 +-- .../argnames/query_one_edgeql.py.assert | 4 +-- .../generated_async_edgeql.py.assert | 32 +++++++++---------- .../object/link_prop_async_edgeql.py.assert | 4 +-- .../object/link_prop_edgeql.py.assert | 4 +-- .../select_object_async_edgeql.py.assert | 4 +-- .../object/select_object_edgeql.py.assert | 4 +-- .../select_objects_async_edgeql.py.assert | 4 +-- .../object/select_objects_edgeql.py.assert | 4 +-- .../parpkg/select_args_async_edgeql.py.assert | 4 +-- .../parpkg/select_args_edgeql.py.assert | 4 +-- .../subpkg/my_query_async_edgeql.py.assert | 4 +-- .../parpkg/subpkg/my_query_edgeql.py.assert | 4 +-- .../select_scalar_async_edgeql.py.assert | 4 +-- .../scalar/select_scalar_edgeql.py.assert | 4 +-- .../select_scalars_async_edgeql.py.assert | 4 +-- .../scalar/select_scalars_edgeql.py.assert | 4 +-- 25 files changed, 70 insertions(+), 70 deletions(-) diff --git a/edgedb/codegen/generator.py b/edgedb/codegen/generator.py index 359dd034..f357d50a 100644 --- a/edgedb/codegen/generator.py +++ b/edgedb/codegen/generator.py @@ -318,9 +318,9 @@ def _generate( print(f"def {name}(", file=buf) self._imports.add("edgedb") if self._async: - print(f"{INDENT}client: edgedb.AsyncIOClient,", file=buf) + print(f"{INDENT}executor: edgedb.AsyncIOExecutor,", file=buf) else: - print(f"{INDENT}client: edgedb.Client,", file=buf) + print(f"{INDENT}executor: edgedb.Executor,", file=buf) if kw_only: print(f"{INDENT}*,", file=buf) for name, arg in args.items(): @@ -337,9 +337,9 @@ def _generate( rt = "return " if self._async: - print(f"{INDENT}{rt}await client.{method}(", file=buf) + print(f"{INDENT}{rt}await executor.{method}(", file=buf) else: - print(f"{INDENT}{rt}client.{method}(", file=buf) + print(f"{INDENT}{rt}executor.{method}(", file=buf) print(f'{INDENT}{INDENT}"""\\', file=buf) print( textwrap.indent( diff --git a/tests/codegen/linked/test_linked_async_edgeql.py.assert b/tests/codegen/linked/test_linked_async_edgeql.py.assert index 29c6291b..e54e2622 100644 --- a/tests/codegen/linked/test_linked_async_edgeql.py.assert +++ b/tests/codegen/linked/test_linked_async_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb async def test_linked( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select 42\ """, diff --git a/tests/codegen/linked/test_linked_edgeql.py.assert b/tests/codegen/linked/test_linked_edgeql.py.assert index 2c3c0410..00a1b169 100644 --- a/tests/codegen/linked/test_linked_edgeql.py.assert +++ b/tests/codegen/linked/test_linked_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb def test_linked( - client: edgedb.Client, + executor: edgedb.Executor, ) -> int: - return client.query_single( + return executor.query_single( """\ select 42\ """, diff --git a/tests/codegen/test-project1/generated_async_edgeql.py.assert b/tests/codegen/test-project1/generated_async_edgeql.py.assert index d35b5528..f4e8fea7 100644 --- a/tests/codegen/test-project1/generated_async_edgeql.py.assert +++ b/tests/codegen/test-project1/generated_async_edgeql.py.assert @@ -24,10 +24,10 @@ class SelectOptionalJsonResultItemSnakeCase: async def select_optional_json( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, arg0: str | None, ) -> list[tuple[str, SelectOptionalJsonResultItem]]: - return await client.query( + return await executor.query( """\ create type TestCase { create link snake_case -> TestCase; @@ -40,9 +40,9 @@ async def select_optional_json( async def select_scalar( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select 1;\ """, @@ -50,9 +50,9 @@ async def select_scalar( async def test_linked( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select 42\ """, diff --git a/tests/codegen/test-project1/select_optional_json_async_edgeql.py.assert b/tests/codegen/test-project1/select_optional_json_async_edgeql.py.assert index b4b3be36..8588dd54 100644 --- a/tests/codegen/test-project1/select_optional_json_async_edgeql.py.assert +++ b/tests/codegen/test-project1/select_optional_json_async_edgeql.py.assert @@ -30,10 +30,10 @@ class SelectOptionalJsonResultItemSnakeCase(NoPydanticValidation): async def select_optional_json( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, arg0: typing.Optional[str], ) -> typing.List[typing.Tuple[str, SelectOptionalJsonResultItem]]: - return await client.query( + return await executor.query( """\ create type TestCase { create link snake_case -> TestCase; diff --git a/tests/codegen/test-project1/select_optional_json_edgeql.py.assert b/tests/codegen/test-project1/select_optional_json_edgeql.py.assert index a9bf6391..004dd27c 100644 --- a/tests/codegen/test-project1/select_optional_json_edgeql.py.assert +++ b/tests/codegen/test-project1/select_optional_json_edgeql.py.assert @@ -21,10 +21,10 @@ class SelectOptionalJsonResultItemSnakeCase: def select_optional_json( - client: edgedb.Client, + executor: edgedb.Executor, arg0: typing.Optional[str], ) -> list[tuple[str, SelectOptionalJsonResultItem]]: - return client.query( + return executor.query( """\ create type TestCase { create link snake_case -> TestCase; diff --git a/tests/codegen/test-project1/select_scalar_async_edgeql.py.assert b/tests/codegen/test-project1/select_scalar_async_edgeql.py.assert index d68a5d32..6312fe0e 100644 --- a/tests/codegen/test-project1/select_scalar_async_edgeql.py.assert +++ b/tests/codegen/test-project1/select_scalar_async_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb async def select_scalar( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select 1;\ """, diff --git a/tests/codegen/test-project1/select_scalar_edgeql.py.assert b/tests/codegen/test-project1/select_scalar_edgeql.py.assert index 227c30d2..4c870f1b 100644 --- a/tests/codegen/test-project1/select_scalar_edgeql.py.assert +++ b/tests/codegen/test-project1/select_scalar_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb def select_scalar( - client: edgedb.Client, + executor: edgedb.Executor, ) -> int: - return client.query_single( + return executor.query_single( """\ select 1;\ """, diff --git a/tests/codegen/test-project2/argnames/query_one_async_edgeql.py.assert b/tests/codegen/test-project2/argnames/query_one_async_edgeql.py.assert index 2f1fcaf3..cbfb0961 100644 --- a/tests/codegen/test-project2/argnames/query_one_async_edgeql.py.assert +++ b/tests/codegen/test-project2/argnames/query_one_async_edgeql.py.assert @@ -7,11 +7,11 @@ import edgedb async def query_one( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, *, arg_name_with_underscores: int, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select $arg_name_with_underscores\ """, diff --git a/tests/codegen/test-project2/argnames/query_one_edgeql.py.assert b/tests/codegen/test-project2/argnames/query_one_edgeql.py.assert index 3e874faa..c7cfe601 100644 --- a/tests/codegen/test-project2/argnames/query_one_edgeql.py.assert +++ b/tests/codegen/test-project2/argnames/query_one_edgeql.py.assert @@ -7,11 +7,11 @@ import edgedb def query_one( - client: edgedb.Client, + executor: edgedb.Executor, *, arg_name_with_underscores: int, ) -> int: - return client.query_single( + return executor.query_single( """\ select $arg_name_with_underscores\ """, diff --git a/tests/codegen/test-project2/generated_async_edgeql.py.assert b/tests/codegen/test-project2/generated_async_edgeql.py.assert index 1d7add5d..40e256ba 100644 --- a/tests/codegen/test-project2/generated_async_edgeql.py.assert +++ b/tests/codegen/test-project2/generated_async_edgeql.py.assert @@ -135,9 +135,9 @@ class SelectObjectResultParamsItem: async def link_prop( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> list[LinkPropResult]: - return await client.query( + return await executor.query( """\ create type Person { create required property name -> str; @@ -162,7 +162,7 @@ async def link_prop( async def my_query( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, *, a: uuid.UUID, b: uuid.UUID | None, @@ -215,7 +215,7 @@ async def my_query( aw: edgedb.Range[datetime.date], ax: edgedb.Range[datetime.date] | None, ) -> MyQueryResult: - return await client.query_single( + return await executor.query_single( """\ create scalar type MyScalar extending int64; create scalar type MyEnum extending enum; @@ -331,11 +331,11 @@ async def my_query( async def query_one( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, *, arg_name_with_underscores: int, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select $arg_name_with_underscores\ """, @@ -344,12 +344,12 @@ async def query_one( async def select_args( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, *, arg_str: str, arg_datetime: datetime.datetime, ) -> SelectArgsResult: - return await client.query_single( + return await executor.query_single( """\ select { Str := $arg_str, @@ -362,9 +362,9 @@ async def select_args( async def select_object( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> SelectObjectResult | None: - return await client.query_single( + return await executor.query_single( """\ select schema::Function { Name := .name, @@ -380,9 +380,9 @@ async def select_object( async def select_objects( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> list[SelectObjectResult]: - return await client.query( + return await executor.query( """\ select schema::Function { Name := .name, @@ -397,9 +397,9 @@ async def select_objects( async def select_scalar( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select 1;\ """, @@ -407,9 +407,9 @@ async def select_scalar( async def select_scalars( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> list[edgedb.ConfigMemory]: - return await client.query( + return await executor.query( """\ select {1, 2, 3};\ """, diff --git a/tests/codegen/test-project2/object/link_prop_async_edgeql.py.assert b/tests/codegen/test-project2/object/link_prop_async_edgeql.py.assert index 8937f0d0..c4e9ad8a 100644 --- a/tests/codegen/test-project2/object/link_prop_async_edgeql.py.assert +++ b/tests/codegen/test-project2/object/link_prop_async_edgeql.py.assert @@ -46,9 +46,9 @@ class LinkPropResultFriendsItem(NoPydanticValidation): async def link_prop( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> typing.List[LinkPropResult]: - return await client.query( + return await executor.query( """\ create type Person { create required property name -> str; diff --git a/tests/codegen/test-project2/object/link_prop_edgeql.py.assert b/tests/codegen/test-project2/object/link_prop_edgeql.py.assert index ccbc8dec..3eaf4ddb 100644 --- a/tests/codegen/test-project2/object/link_prop_edgeql.py.assert +++ b/tests/codegen/test-project2/object/link_prop_edgeql.py.assert @@ -36,9 +36,9 @@ class LinkPropResultFriendsItem: def link_prop( - client: edgedb.Client, + executor: edgedb.Executor, ) -> list[LinkPropResult]: - return client.query( + return executor.query( """\ create type Person { create required property name -> str; diff --git a/tests/codegen/test-project2/object/select_object_async_edgeql.py.assert b/tests/codegen/test-project2/object/select_object_async_edgeql.py.assert index a3c75670..70c1bae8 100644 --- a/tests/codegen/test-project2/object/select_object_async_edgeql.py.assert +++ b/tests/codegen/test-project2/object/select_object_async_edgeql.py.assert @@ -34,9 +34,9 @@ class SelectObjectResultParamsItem(NoPydanticValidation): async def select_object( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> typing.Optional[SelectObjectResult]: - return await client.query_single( + return await executor.query_single( """\ select schema::Function { Name := .name, diff --git a/tests/codegen/test-project2/object/select_object_edgeql.py.assert b/tests/codegen/test-project2/object/select_object_edgeql.py.assert index 3786486d..c3ebb60e 100644 --- a/tests/codegen/test-project2/object/select_object_edgeql.py.assert +++ b/tests/codegen/test-project2/object/select_object_edgeql.py.assert @@ -25,9 +25,9 @@ class SelectObjectResultParamsItem: def select_object( - client: edgedb.Client, + executor: edgedb.Executor, ) -> typing.Optional[SelectObjectResult]: - return client.query_single( + return executor.query_single( """\ select schema::Function { Name := .name, diff --git a/tests/codegen/test-project2/object/select_objects_async_edgeql.py.assert b/tests/codegen/test-project2/object/select_objects_async_edgeql.py.assert index 3742d198..b293172a 100644 --- a/tests/codegen/test-project2/object/select_objects_async_edgeql.py.assert +++ b/tests/codegen/test-project2/object/select_objects_async_edgeql.py.assert @@ -34,9 +34,9 @@ class SelectObjectsResultParamsItem(NoPydanticValidation): async def select_objects( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> typing.List[SelectObjectsResult]: - return await client.query( + return await executor.query( """\ select schema::Function { Name := .name, diff --git a/tests/codegen/test-project2/object/select_objects_edgeql.py.assert b/tests/codegen/test-project2/object/select_objects_edgeql.py.assert index 1c6cd231..fed335d7 100644 --- a/tests/codegen/test-project2/object/select_objects_edgeql.py.assert +++ b/tests/codegen/test-project2/object/select_objects_edgeql.py.assert @@ -25,9 +25,9 @@ class SelectObjectsResultParamsItem: def select_objects( - client: edgedb.Client, + executor: edgedb.Executor, ) -> list[SelectObjectsResult]: - return client.query( + return executor.query( """\ select schema::Function { Name := .name, diff --git a/tests/codegen/test-project2/parpkg/select_args_async_edgeql.py.assert b/tests/codegen/test-project2/parpkg/select_args_async_edgeql.py.assert index 14d293aa..7485f3aa 100644 --- a/tests/codegen/test-project2/parpkg/select_args_async_edgeql.py.assert +++ b/tests/codegen/test-project2/parpkg/select_args_async_edgeql.py.assert @@ -26,12 +26,12 @@ class SelectArgsResult(NoPydanticValidation): async def select_args( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, *, arg_str: str, arg_datetime: datetime.datetime, ) -> SelectArgsResult: - return await client.query_single( + return await executor.query_single( """\ select { Str := $arg_str, diff --git a/tests/codegen/test-project2/parpkg/select_args_edgeql.py.assert b/tests/codegen/test-project2/parpkg/select_args_edgeql.py.assert index b5e961b0..cc0d8cfc 100644 --- a/tests/codegen/test-project2/parpkg/select_args_edgeql.py.assert +++ b/tests/codegen/test-project2/parpkg/select_args_edgeql.py.assert @@ -17,12 +17,12 @@ class SelectArgsResult: def select_args( - client: edgedb.Client, + executor: edgedb.Executor, *, arg_str: str, arg_datetime: datetime.datetime, ) -> SelectArgsResult: - return client.query_single( + return executor.query_single( """\ select { Str := $arg_str, diff --git a/tests/codegen/test-project2/parpkg/subpkg/my_query_async_edgeql.py.assert b/tests/codegen/test-project2/parpkg/subpkg/my_query_async_edgeql.py.assert index ddcdffd8..ba841cc8 100644 --- a/tests/codegen/test-project2/parpkg/subpkg/my_query_async_edgeql.py.assert +++ b/tests/codegen/test-project2/parpkg/subpkg/my_query_async_edgeql.py.assert @@ -88,7 +88,7 @@ class MyQueryResult(NoPydanticValidation): async def my_query( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, *, a: uuid.UUID, b: typing.Optional[uuid.UUID], @@ -141,7 +141,7 @@ async def my_query( aw: edgedb.Range[datetime.date], ax: typing.Optional[edgedb.Range[datetime.date]], ) -> MyQueryResult: - return await client.query_single( + return await executor.query_single( """\ create scalar type MyScalar extending int64; create scalar type MyEnum extending enum; diff --git a/tests/codegen/test-project2/parpkg/subpkg/my_query_edgeql.py.assert b/tests/codegen/test-project2/parpkg/subpkg/my_query_edgeql.py.assert index 52a15122..00fd747a 100644 --- a/tests/codegen/test-project2/parpkg/subpkg/my_query_edgeql.py.assert +++ b/tests/codegen/test-project2/parpkg/subpkg/my_query_edgeql.py.assert @@ -79,7 +79,7 @@ class MyQueryResult: def my_query( - client: edgedb.Client, + executor: edgedb.Executor, *, a: uuid.UUID, b: typing.Optional[uuid.UUID], @@ -132,7 +132,7 @@ def my_query( aw: edgedb.Range[datetime.date], ax: typing.Optional[edgedb.Range[datetime.date]], ) -> MyQueryResult: - return client.query_single( + return executor.query_single( """\ create scalar type MyScalar extending int64; create scalar type MyEnum extending enum; diff --git a/tests/codegen/test-project2/scalar/select_scalar_async_edgeql.py.assert b/tests/codegen/test-project2/scalar/select_scalar_async_edgeql.py.assert index 93c4c048..a9fc5917 100644 --- a/tests/codegen/test-project2/scalar/select_scalar_async_edgeql.py.assert +++ b/tests/codegen/test-project2/scalar/select_scalar_async_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb async def select_scalar( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> int: - return await client.query_single( + return await executor.query_single( """\ select 1;\ """, diff --git a/tests/codegen/test-project2/scalar/select_scalar_edgeql.py.assert b/tests/codegen/test-project2/scalar/select_scalar_edgeql.py.assert index e2c7abe5..c8cfeb1b 100644 --- a/tests/codegen/test-project2/scalar/select_scalar_edgeql.py.assert +++ b/tests/codegen/test-project2/scalar/select_scalar_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb def select_scalar( - client: edgedb.Client, + executor: edgedb.Executor, ) -> int: - return client.query_single( + return executor.query_single( """\ select 1;\ """, diff --git a/tests/codegen/test-project2/scalar/select_scalars_async_edgeql.py.assert b/tests/codegen/test-project2/scalar/select_scalars_async_edgeql.py.assert index fa8c8a39..d7e9b233 100644 --- a/tests/codegen/test-project2/scalar/select_scalars_async_edgeql.py.assert +++ b/tests/codegen/test-project2/scalar/select_scalars_async_edgeql.py.assert @@ -8,9 +8,9 @@ import typing async def select_scalars( - client: edgedb.AsyncIOClient, + executor: edgedb.AsyncIOExecutor, ) -> typing.List[edgedb.ConfigMemory]: - return await client.query( + return await executor.query( """\ select {1, 2, 3};\ """, diff --git a/tests/codegen/test-project2/scalar/select_scalars_edgeql.py.assert b/tests/codegen/test-project2/scalar/select_scalars_edgeql.py.assert index cfedc1ce..74016c24 100644 --- a/tests/codegen/test-project2/scalar/select_scalars_edgeql.py.assert +++ b/tests/codegen/test-project2/scalar/select_scalars_edgeql.py.assert @@ -7,9 +7,9 @@ import edgedb def select_scalars( - client: edgedb.Client, + executor: edgedb.Executor, ) -> list[edgedb.ConfigMemory]: - return client.query( + return executor.query( """\ select {1, 2, 3};\ """,