Skip to content

Commit

Permalink
Amend tests and documentation for natural joins
Browse files Browse the repository at this point in the history
These amendments are made in anticipation of the following library changes
(discussed in #66)

- Cross joins should not have any qualifiers
- Therefore natural cross joins should also not exist
  • Loading branch information
sneakertack committed Apr 15, 2015
1 parent 4437287 commit 2cf8978
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
<li>- <a href="#join">join, leftJoin, rightJoin, fullJoin, crossJoin</a></li>
<li>- <a href="#on">on</a></li>
<li>- <a href="#using">using</a></li>
<li>- <a href="#join">naturalJoin, naturalLeftJoin, naturalRightJoin, naturalFullJoin, naturalCrossJoin</a></li>
<li>- <a href="#naturaljoin">naturalJoin, naturalLeftJoin, naturalRightJoin, naturalFullJoin</a></li>
<li>- <a href="#selwhere">where</a></li>
<li>- <a href="#groupBy">groupBy</a></li>
<li>- <a href="#having">having</a></li>
Expand Down Expand Up @@ -361,6 +361,7 @@ <h2 id="select">select</h2>
<span class="alias">Aliases: <b>innerJoin, leftOuterJoin, rightOuterJoin, fullOuterJoin</b></span>
<br />
<p>Adds the specified join to the query. <b>tbl</b> can include an alias after a space or after the <tt>'AS'</tt> keyword (<tt>'my_table my_alias'</tt>). <b>onCriteria</b> is optional if a <a href="#joinCriteria">joinCriteria</a> function has been supplied.</p>
<p><i>Note: <b>crossJoin</b> will ignore any <b>onCriteria</b> argument, if supplied.</i></p>
<pre>
select().from('person').join('address', {'person.addr_id': 'address.id'});
// SELECT * FROM person INNER JOIN address ON person.addr_id = address.id
Expand Down Expand Up @@ -403,7 +404,7 @@ <h2 id="select">select</h2>
</pre>
</p>
<p id="naturaljoin">
<b class="header">naturalJoin, naturalLeftJoin, naturalRightJoin, naturalFullJoin, naturalCrossJoin</b><br />
<b class="header">naturalJoin, naturalLeftJoin, naturalRightJoin, naturalFullJoin</b><br />
<code>sel.naturalJoin(tbl)</code><br />
<span class="alias">Aliases: <b>naturalInnerJoin, naturalLeftOuterJoin, naturalRightOuterJoin, naturalFullOuterJoin</b></span>
<br />
Expand Down
7 changes: 1 addition & 6 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ describe('SQL Bricks', function() {
it('.crossJoin() should generate a cross join', function() {
check(select().from('usr').crossJoin('addr'),
'SELECT * FROM "user" usr ' +
'CROSS JOIN address addr ON usr.addr_fk = addr.pk');
'CROSS JOIN address addr');
});
it('join() should accept an expression for the on argument', function() {
check(select().from('usr').join('addr', eq('usr.addr_id', sql('addr.id'))),
Expand Down Expand Up @@ -615,11 +615,6 @@ describe('SQL Bricks', function() {
'SELECT * FROM "user" usr ' +
'NATURAL FULL JOIN address addr');
});
it('.naturalCrossJoin() should generate a natural cross join', function() {
check(select().from('usr').naturalCrossJoin('addr'),
'SELECT * FROM "user" usr ' +
'NATURAL CROSS JOIN address addr');
});
});

describe('WHERE clauses', function() {
Expand Down

0 comments on commit 2cf8978

Please sign in to comment.