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

Query params in config commands #5670

Merged
merged 1 commit into from Jun 19, 2023
Merged

Query params in config commands #5670

merged 1 commit into from Jun 19, 2023

Conversation

aljazerzen
Copy link
Contributor

@aljazerzen aljazerzen commented Jun 16, 2023

Closes #4934

Comment on lines 220 to +225
# ConfigSet and ConfigReset don't like being part of a Set, so bail early
if isinstance(ir.expr, (irast.ConfigSet, irast.ConfigReset)):
ir.expr.scope_tree = ctx.path_scope
ir.expr.globals = list(ctx.env.query_globals.values())
ir.expr.params = params
ir.expr.schema = ctx.env.schema
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@msullivan from the top of your head, is there an obvious blocker that prevents ConfigCommand be a part of Statement?

If you don't think of one, I'll try to fit it in (in a following PR)

Copy link
Member

Choose a reason for hiding this comment

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

The top-level thing is that Statement wants expr to be a Set and apparently "ConfigSet and ConfigReset don't like being part of a Set, so bail early".

I think I skipped investigating that the last time I hit this because I didn't (and, honestly, don't) understand the backend config compiler and didn't want to go down a rabbit hole, but I think it should be possible

Copy link
Member

@msullivan msullivan left a comment

Choose a reason for hiding this comment

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

This is great!

@@ -404,6 +404,20 @@ async def test_edgeql_globals_12(self):
[16]
)

async def test_edgeql_globals_13(self):
Copy link
Member

Choose a reason for hiding this comment

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

Could we add a test with config commands too? I seem to recall we might try to use the static evaluator on those so it's worth seeing what happens

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure if this is possible. The non-global "config set" commands we have are:

  • set module mod;
  • set alias al as module mod;

https://www.edgedb.com/docs/reference/edgeql/sess_set_alias#set

Copy link
Member

Choose a reason for hiding this comment

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

@@ -65,7 +65,7 @@ def compile_ir_to_sql_tree(
]
] = None,
backend_runtime_params: Optional[pgparams.BackendRuntimeParams]=None,
) -> Tuple[pgast.Base, context.Environment]:
Copy link
Member

Choose a reason for hiding this comment

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

Maybe these functions ought to return a namedtuple or a dataclass. Doesn't need to happen now though.

@aljazerzen aljazerzen merged commit 09d034f into master Jun 19, 2023
21 checks passed
@aljazerzen aljazerzen deleted the param-for-globals branch June 19, 2023 07:06
aljazerzen added a commit that referenced this pull request Jun 22, 2023
Followup for #5670

- replace a few tuples in return types with dataclasses,

- create "complexity bottle necks" of invocations of pgcompiler and pgcodegen
  - with this I mean that I tried to reduce the number of entry points to
    specific parts of the codebase,
  - I've also converted a few classmethods into regular functions, because they
    were doing some `super().__class__(**kwargs)` that I find ugly,

- move entrypoints and "important stuff" to the top of a file and auxilary
  functions and classes down (important stuff is generally anything public,
  used beyond current file).
aljazerzen added a commit that referenced this pull request Jun 28, 2023
Followup for #5670

- replace a few tuples in return types with dataclasses,

- create "complexity bottle necks" of invocations of pgcompiler and pgcodegen
  - with this I mean that I tried to reduce the number of entry points to
    specific parts of the codebase,
  - I've also converted a few classmethods into regular functions, because they
    were doing some `super().__class__(**kwargs)` that I find ugly,

- move entrypoints and "important stuff" to the top of a file and auxilary
  functions and classes down (important stuff is generally anything public,
  used beyond current file).
aljazerzen added a commit that referenced this pull request Jun 29, 2023
Followup for #5670

- replace a few tuples in return types with dataclasses,

- create "complexity bottle necks" of invocations of pgcompiler and pgcodegen
  - with this I mean that I tried to reduce the number of entry points to
    specific parts of the codebase,
  - I've also converted a few classmethods into regular functions, because they
    were doing some `super().__class__(**kwargs)` that I find ugly,

- move entrypoints and "important stuff" to the top of a file and auxilary
  functions and classes down (important stuff is generally anything public,
  used beyond current file).
msullivan pushed a commit that referenced this pull request Sep 23, 2023
@msullivan msullivan mentioned this pull request Sep 23, 2023
msullivan pushed a commit that referenced this pull request Sep 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when trying to set a global variable using a query parameter
2 participants