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

Convert selecting a named tuple into a free object #776

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

scotttrinh
Copy link
Collaborator

@scotttrinh scotttrinh commented Nov 10, 2023

Right now we do not allow selecting shapes on named tuples, so in order to support FTS, the simplest way forward is to convert any named tuples to a free object using a for expression.

There is one outstanding issue edgedb/edgedb#6530 that requires an additional (hopefully temporary) hack for the output of fts::search to work properly: the compiler complains that the object computed in the resulting free object is not distinct, so we apply distinct to all of the named tuple's properties which should be a no-op.

There is some talk about making the output of fts::search into a free object in it's own right in the future, which is fine: everything will just work but now the query builder will be able to select shapes from named tuples.

expr = $for(expr as TypeSet<NamedTupleType>, (forScope) => {
const shape: any = {};
for (const k of Object.keys(forScope.__element__.__shape__)) {
shape[k] = op("distinct", (forScope as any)[k]);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This distinct operator is a hack for dealing with edgedb/edgedb#6530.

@scotttrinh scotttrinh marked this pull request as ready for review November 30, 2023 14:25
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.

1 participant