-
Notifications
You must be signed in to change notification settings - Fork 46
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
Default to None for generated functions with defaults #422
Comments
fantix
added a commit
that referenced
this issue
Jun 19, 2024
New Features ============ * Support EdgeDB 5.0 "branch" connection option (by @vpetrovykh in #484 #485 #487) * Support EdgeDB 5.0 AI extension (by @fantix in #489 #490) Breaking Changes ================ * Enum values can now compare to user-defined enums successfully (#425) (by @fantix in bb7522c for #419) * Add optional default to codegen params (#426) (by @fantix in 21b024a for #422) Changes ======= * blocking client: fix connect and timeout, support IPv6 (#499) (by @fantix @zachary822 in 28a83fd for #486) Fixes ===== * Add test to check setting a computed global using with_globals. (#494) (by @dnwpark in 636bc0e for #494) * Fix test and add Python 3.12 in CI (by @fantix in #498 #503) * Use result of pydantic_dataclass, will silence linters (#501) (by @AdrienPensart in d88187a) * Extract ExecuteContext as in/out argument (#500) (by @fantix in 2fb7965 for #493)
Merged
fantix
added a commit
that referenced
this issue
Jun 19, 2024
New Features ============ * Support EdgeDB 5.0 "branch" connection option (by @vpetrovykh in #484 #485 #487) * Support EdgeDB 5.0 AI extension (by @fantix in #489 #490) Breaking Changes ================ * Enum values can now compare to user-defined enums successfully (#425) (by @fantix in bb7522c for #419) * Add optional default to codegen params (#426) (by @fantix in 21b024a for #422) Changes ======= * blocking client: fix connect and timeout, support IPv6 (#499) (by @fantix @zachary822 in 28a83fd for #486) Fixes ===== * Add test to check setting a computed global using with_globals. (#494) (by @dnwpark in 636bc0e for #494) * Fix test and add Python 3.12 in CI (by @fantix in #498 #503) * Use result of pydantic_dataclass, will silence linters (#501) (by @AdrienPensart in d88187a) * Extract ExecuteContext as in/out argument (#500) (by @fantix in 2fb7965 for #493)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
The python code generator does not allow the caller to skip optional parameters, as it requires every parameter
to be passed as None for these be skipped.
For example, see the code in the tests:
edgedb-python/tests/codegen/test-project2/generated_async_edgeql.py.assert
Lines 198 to 216 in a5067ef
This can make "update" calls somewhat cumbersome, as it requires spelling out all fields that are not being updated as
None
.Reference discord thread: https://discord.com/channels/841451783728529451/849374935209607199/1081881229676265592
Reproduction
Generate code with
edge-py
using a query that includes a number of optional parameters.Expected behavior
I'd like to see something like
type | None = None
which would bring it in-line with how Typescript parameters work: https://www.edgedb.com/docs/clients/js/parameters#optional-parametersAs a workaround, I created a helper function that copies all parameters from the generated function but defaults to None for the optional arguments.
Versions (please complete the following information):
edgedb-python
version: 1.3.0Additional context
Note: I raised another issue related to generated code and enum values here: #419
The text was updated successfully, but these errors were encountered: