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

types: allow EntityQuery to select from many tables #62

Merged
merged 3 commits into from
Apr 9, 2024
Merged

Conversation

tantaman
Copy link

@tantaman tantaman commented Apr 5, 2024

Doing join will bring in more tables that can be selected against. Thus, EntityQuery.select needs to be able pull from more than a single schema.

To do that, EntityQuery now takes a FromSet rather than EntitySchema.

type FromSet = {
  [table: string]: EntitySchema
};

const q = new EntityQuery<{issue: Issue}>();
const q2 = new EntityQuery<{user: User}>();

q.join(q2, 'owner', 'issue.ownerId', 'owner.id').select(...);

join requires us to support aliasing ambiguous columns so this adds that as well.

image

// aliasing: x as y
foo.select(['x', 'y'])
// qualifying
foo.select('foo.bar', 'baz.x').join(Baz, 'baz_id', 'id');
// unqualified works too if the column is not ambiguous
foo.select('bar');
// added support for *
foo.select('issue.*')
Screenshot 2024-04-04 at 11 26 54 PM

@tantaman tantaman changed the title join types: allow EntityQuery to select from many tables types: allow EntityQuery to select from many tables Apr 5, 2024
@arv arv force-pushed the mlaw/entity-schema branch from d8818ce to c53d1e6 Compare April 8, 2024 08:59
Base automatically changed from mlaw/entity-schema to main April 8, 2024 09:32
@tantaman tantaman force-pushed the mlaw/from-set branch 2 times, most recently from 3a6f6c2 to 70ac0dd Compare April 8, 2024 12:06
@tantaman
Copy link
Author

tantaman commented Apr 8, 2024

Merged with @arv 's latest changes around complex where conditions.

Copy link
Contributor

@arv arv left a comment

Choose a reason for hiding this comment

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

LGTM

src/zql/ast-to-ivm/pipeline-builder.ts Outdated Show resolved Hide resolved
src/zql/query/entity-query.ts Outdated Show resolved Hide resolved
tantaman added 3 commits April 8, 2024 20:41
E.g., since we'll have join and join introduces different tables into a query:

```ts
s.select('foo.*', 'bar.*')
```
@tantaman tantaman merged commit 22c5252 into main Apr 9, 2024
4 checks passed
@tantaman tantaman deleted the mlaw/from-set branch April 9, 2024 01:03
tantaman added a commit to rocicorp/mono that referenced this pull request Apr 9, 2024
tantaman added a commit to rocicorp/mono that referenced this pull request Apr 9, 2024
tantaman added a commit to rocicorp/mono that referenced this pull request Apr 9, 2024
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.

2 participants