Skip to content

Commit

Permalink
Fixed the bug of missing relation names in join relational algebra st…
Browse files Browse the repository at this point in the history
…atements

Signed-off-by: Michael Mior <[email protected]>
Signed-off-by: Michael Mior <[email protected]>
  • Loading branch information
axj2613 authored and michaelmior committed Dec 22, 2022
1 parent 8fa2dd7 commit 11e2f8e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/RelExpr.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ const RelExpr: StatelessFunctionalComponent<Props> = (props) => {
<Join
type={expr.join.type}
condition={exprToString(expr.join.condition)}
left={exprToString(expr.join.left.relation)}
right={exprToString(expr.join.right.relation)}
/>
);

Expand Down
2 changes: 2 additions & 0 deletions src/RelExprTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ const RelExprTree: StatelessFunctionalComponent<Props> = (props) => {
<Join
type={expr.join.type}
condition={exprToString(expr.join.condition)}
left={exprToString(expr.join.left.relation)}
right={exprToString(expr.join.right.relation)}
/>
);
case 'except':
Expand Down
8 changes: 5 additions & 3 deletions src/RelOp.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,25 @@ export const Intersect: StatelessFunctionalComponent<{||}> = () => (
export const Join: StatelessFunctionalComponent<{
type: string,
condition: string,
left: string,
right: string,
}> = (props) => {
if (props.type === 'left') {
return (
<span>
<sub>{props.condition}</sub>
{props.left} <sub>{props.condition}</sub> {props.right}
</span>
);
} else if (props.type === 'right') {
return (
<span>
<sub>{props.condition}</sub>
{props.left} <sub>{props.condition}</sub> {props.right}
</span>
);
} else {
return (
<span>
<sub>{props.condition}</sub>
{props.left} <sub>{props.condition}</sub> {props.right}
</span>
);
}
Expand Down
11 changes: 5 additions & 6 deletions src/RelOp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
Join,
Union,
} from './RelOp';
import {exprToString} from './util';

each([
['unary operators', <UnaryRelOp />],
Expand Down Expand Up @@ -88,23 +87,23 @@ it('renders a Product', () => {
/** @test {Join} */
it('renders an inner Join', () => {
const {container} = render(
<Join type={'inner'} condition={'foo=3 ∧ bar=2'} />
<Join type={'inner'} left={'A'} condition={'foo=3 ∧ bar=2'} right={'B'} />
);
expect(container).toContainHTML('⋈<sub>foo=3 ∧ bar=2</sub>');
expect(container).toContainHTML('A ⋈<sub>foo=3 ∧ bar=2</sub> B');
});

/** @test {Join} */
it('renders a left outer Join', () => {
const {container} = render(
<Join type={'left'} condition={'foo=3 ∧ bar=2'} />
<Join type={'left'} left={'A'} condition={'foo=3 ∧ bar=2'} right={'B'} />
);
expect(container).toContainHTML('⟕<sub>foo=3 ∧ bar=2</sub>');
expect(container).toContainHTML('A ⟕<sub>foo=3 ∧ bar=2</sub> B');
});

/** @test {Join} */
it('renders a right outer Join', () => {
const {container} = render(
<Join type={'right'} condition={'foo=3 ∧ bar=2'} />
<Join type={'right'} left={'A'} condition={'foo=3 ∧ bar=2'} right={'B'} />
);
expect(container).toContainHTML('⟖<sub>foo=3 ∧ bar=2</sub>');
});
Expand Down

1 comment on commit 11e2f8e

@vercel
Copy link

@vercel vercel bot commented on 11e2f8e Dec 22, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.