diff options
author | Harel Ben-Attia <harelba@gmail.com> | 2014-06-07 13:18:21 -0400 |
---|---|---|
committer | Harel Ben-Attia <harelba@gmail.com> | 2014-06-07 13:18:21 -0400 |
commit | 362037af50d8e3d934355c8bb2be8b4b1ee010c2 (patch) | |
tree | e48de3e3fea992e5434158eece2e68c72ddd3fd6 /test | |
parent | 9bfca3f98e6a704bb178845c53dd20208f8492e8 (diff) |
Removed need for random temp tables + added join tests
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-suite | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/test/test-suite b/test/test-suite index b675270..bdf8dfb 100755 --- a/test/test-suite +++ b/test/test-suite @@ -951,6 +951,54 @@ class SqlTests(AbstractQTestCase): self.assertEquals(o[1], 'ppp dip.1@otherdomain.com') self.assertEquals(o[2], 'ppp dip.2@otherdomain.com') + def test_self_join1(self): + tmpfile = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) + cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c1 = a2.c1)"' % (tmpfile.name,tmpfile.name) + retcode, o, e = run_command(cmd) + + self.assertEquals(retcode, 0) + self.assertEquals(len(e), 0) + self.assertEquals(len(o), 10) + + self.cleanup(tmpfile) + + def test_self_join_reuses_table(self): + tmpfile = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) + cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c1 = a2.c1)" -A' % (tmpfile.name,tmpfile.name) + retcode, o, e = run_command(cmd) + + self.assertEquals(retcode, 0) + self.assertEquals(len(e), 0) + self.assertEquals(len(o), 3) + + self.assertEquals(o[0],'Table for file: %s' % tmpfile.name) + self.assertEquals(o[1],' `c1` - int') + self.assertEquals(o[2],' `c2` - int') + + self.cleanup(tmpfile) + + def test_self_join2(self): + tmpfile1 = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) + cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c2 = a2.c2)"' % (tmpfile1.name,tmpfile1.name) + retcode, o, e = run_command(cmd) + + self.assertEquals(retcode, 0) + self.assertEquals(len(e), 0) + self.assertEquals(len(o), 10*10) + + self.cleanup(tmpfile1) + + tmpfile2 = self.create_file_with_data("\n".join(["%s 9000" % i for i in range(0,10)])) + cmd = '../bin/q "select * from %s a1 join %s a2 on (a1.c2 = a2.c2) join %s a3 on (a1.c2 = a3.c2)"' % (tmpfile2.name,tmpfile2.name,tmpfile2.name) + retcode, o, e = run_command(cmd) + + self.assertEquals(retcode, 0) + self.assertEquals(len(e), 0) + self.assertEquals(len(o), 10*10*10) + + self.cleanup(tmpfile2) + + def suite(): tl = unittest.TestLoader() basic_stuff = tl.loadTestsFromTestCase(BasicTests) |