Skip to content

Convert selecting a named tuple into a free object#776

Open
scotttrinh wants to merge 15 commits intomasterfrom
named-tuple-to-free-object
Open

Convert selecting a named tuple into a free object#776
scotttrinh wants to merge 15 commits intomasterfrom
named-tuple-to-free-object

Conversation

@scotttrinh
Copy link
Copy Markdown
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 geldata/gel#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.

@scotttrinh scotttrinh force-pushed the named-tuple-to-free-object branch from 3fbacce to 81ae623 Compare November 27, 2023 18:19
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
Copy Markdown
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 geldata/gel#6530.

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