Skip to content

Commit 444af89

Browse files
axj2613michaelmior
authored andcommitted
Fixed the bug of missing relation names in join relational algebra statements
Signed-off-by: Michael Mior <[email protected]>
1 parent 8fa2dd7 commit 444af89

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

src/RelExpr.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ const RelExpr: StatelessFunctionalComponent<Props> = (props) => {
101101
<Join
102102
type={expr.join.type}
103103
condition={exprToString(expr.join.condition)}
104+
left={exprToString(expr.join.left.relation)}
105+
right={exprToString(expr.join.right.relation)}
104106
/>
105107
);
106108

src/RelExprTree.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ const RelExprTree: StatelessFunctionalComponent<Props> = (props) => {
104104
<Join
105105
type={expr.join.type}
106106
condition={exprToString(expr.join.condition)}
107+
left={exprToString(expr.join.left.relation)}
108+
right={exprToString(expr.join.right.relation)}
107109
/>
108110
);
109111
case 'except':

src/RelOp.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,23 +139,25 @@ export const Intersect: StatelessFunctionalComponent<{||}> = () => (
139139
export const Join: StatelessFunctionalComponent<{
140140
type: string,
141141
condition: string,
142+
left: string,
143+
right: string,
142144
}> = (props) => {
143145
if (props.type === 'left') {
144146
return (
145147
<span>
146-
<sub>{props.condition}</sub>
148+
{props.left} <sub>{props.condition}</sub> {props.right}
147149
</span>
148150
);
149151
} else if (props.type === 'right') {
150152
return (
151153
<span>
152-
<sub>{props.condition}</sub>
154+
{props.left} <sub>{props.condition}</sub> {props.right}
153155
</span>
154156
);
155157
} else {
156158
return (
157159
<span>
158-
<sub>{props.condition}</sub>
160+
{props.left} <sub>{props.condition}</sub> {props.right}
159161
</span>
160162
);
161163
}

src/RelOp.test.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
Join,
1616
Union,
1717
} from './RelOp';
18-
import {exprToString} from './util';
1918

2019
each([
2120
['unary operators', <UnaryRelOp />],
@@ -88,23 +87,23 @@ it('renders a Product', () => {
8887
/** @test {Join} */
8988
it('renders an inner Join', () => {
9089
const {container} = render(
91-
<Join type={'inner'} condition={'foo=3 ∧ bar=2'} />
90+
<Join type={'inner'} left={'A'} condition={'foo=3 ∧ bar=2'} right={'B'} />
9291
);
93-
expect(container).toContainHTML('⋈<sub>foo=3 ∧ bar=2</sub>');
92+
expect(container).toContainHTML('A ⋈<sub>foo=3 ∧ bar=2</sub> B');
9493
});
9594

9695
/** @test {Join} */
9796
it('renders a left outer Join', () => {
9897
const {container} = render(
99-
<Join type={'left'} condition={'foo=3 ∧ bar=2'} />
98+
<Join type={'left'} left={'A'} condition={'foo=3 ∧ bar=2'} right={'B'} />
10099
);
101-
expect(container).toContainHTML('⟕<sub>foo=3 ∧ bar=2</sub>');
100+
expect(container).toContainHTML('A ⟕<sub>foo=3 ∧ bar=2</sub> B');
102101
});
103102

104103
/** @test {Join} */
105104
it('renders a right outer Join', () => {
106105
const {container} = render(
107-
<Join type={'right'} condition={'foo=3 ∧ bar=2'} />
106+
<Join type={'right'} left={'A'} condition={'foo=3 ∧ bar=2'} right={'B'} />
108107
);
109108
expect(container).toContainHTML('⟖<sub>foo=3 ∧ bar=2</sub>');
110109
});

0 commit comments

Comments
 (0)