Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Edit syntax for LEFT JOIN.

  • Loading branch information...
commit cf20f07956bdc4a2e3573987e2225cec7131fc74 1 parent f4d58d9
@arcusfelis authored
View
BIN  .eunit/ale.beam
Binary file not shown
View
8 .eunit/ale.erl
@@ -1,8 +0,0 @@
--module(ale).
--export([parse_transform/2]).
-
-
-parse_transform(Forms, _Options) ->
- io:format(user, "Before:\t~p\n\n", [Forms]),
-% io:format(user, "Before:\t~p\n\nAfter:\t~p\n", [Forms, X]),
- Forms.
View
88 .eunit/ale_tests.erl
@@ -1,88 +0,0 @@
--module(ale_tests).
-
--compile({parse_transform, ale}).
--compile(export_all).
-
-
-%% SELECT name, AVG(test_score) FROM student GROUP BY name;
-group_by() ->
- [{S.name, average(S.test_scrote)}
- || S <- table(student), group(S.name)].
-
-%% UPDATE TABLE xyz SET y=z WHERE y=x;
-update() ->
- [[y = Z|XYZ]
- || [z = Z|XYZ] <- table(xyz)].
-
-update2() ->
- [[y = XYZ.z|XYZ]
- || XYZ <- table(xyz)].
-
-
-%% SELECT table1.* FROM table1
-%% LEFT JOIN table2 ON table1.id = tabke2.id WHERE table2.id IS NULL
-left_join() ->
- [T1 || T1 <- table(table1),
- T2 <- join_table(table2), T1.id == T2.id, T2.id =:= undefined].
-
-%% SELECT student.name COUNT(*) FROM student, course
-%% WHERE student.id = course.student_id GROUP BY student.name;
-count() ->
- [{Name, count()}
- || S <- table(student),
- C <- table(course), S.id == C.id, group(S.name)].
-
-
-%% SELECT * FROM t1 ORDER BY f1;
-order_by() ->
- [T || T <- table(t1), order(T.f1)].
-
-
-%% SELECT * FROM t1 ORDER BY f1 DESC;
-order_by_desc() ->
- [T || T <- table(t1), order(reverse(T.f1))].
-
-%% SELECT * FROM t1 ORDER BY f1, f2;
-order_by_multi() ->
- [ T || T <- table(t1), sort([T.f1, T.f2]) ].
-
-%% SELECT * FROM t1 ORDER BY f1 DESC, f2 DESC;
-order_by_multi_desc() ->
- [ T || T <- table(t1), sort(reverse([T.f1, T.f2])) ].
-
-%% SELECT * FROM t1 ORDER BY f1 DESC, f2;
-order_by_multi_desc2() ->
- [ T || T <- table(t1), sort([reverse(T.f1), T.f2]) ].
-
-
-%% SELECT * FROM t1 LIMIT 10, 20;
-limit() ->
- [ T || T <- table(t1), limit(10), offset(20) ].
-
-
-%% SELECT `group`.name, `group`.id, count(client.id) FROM `group`
-%% LEFT JOIN client ON client.group_id = `group`.id
-%% GROUP BY `group`.id HAVING count(client.id) > 3;
-%%
-%% Use having with:
-%% AVG() - Returns the average value
-%% COUNT() - Returns the number of rows
-%% FIRST() - Returns the first value
-%% LAST() - Returns the last value
-%% MAX() - Returns the largest value
-%% MIN() - Returns the smallest value
-%% SUM() - Returns the sum
-having() ->
- [ {G.name, G.id, CC}
- || G <- table(group),
- C <- join_table(client),
- CC = count(C.id),
- group(G.id), C.group_id == G.id, CC > 3].
-
-%% COALESCE(A = B, A IS NULL AND B IS NULL)
-is_exact_equal() ->
- A =:= B.
-
-%% COALESCE(A != B, A IS NOT NULL AND B IS NOT NULL)
-not_exact_equal() ->
- A =/= B.
View
12 .gitignore
@@ -0,0 +1,12 @@
+ebin/*
+deps/*
+*.swp
+*.dump
+*.trace
+.eunit
+.emark
+doc/README.md
+.~*
+*.un~
+c_cov
+fprof.trace
View
2  README.md
@@ -7,5 +7,7 @@ __License__: MIT
__Author__: Uvarov Michael ([`freeakk@gmail.com`](mailto:freeakk@gmail.com))
+__Status__: concept
+
[![Build Status](https://secure.travis-ci.org/freeakk/ale.png?branch=master)](http://travis-ci.org/freeakk/ale)
View
6 test/ale_tests.erl
@@ -23,7 +23,7 @@ update2() ->
%% LEFT JOIN table2 ON table1.id = tabke2.id WHERE table2.id IS NULL
left_join() ->
[T1 || T1 <- table(table1),
- T2 <- join_table(table2), T1.id == T2.id, T2.id =:= undefined].
+ T2 <- table(table2), all(T1), T1.id == T2.id, T2.id =:= undefined].
%% SELECT student.name COUNT(*) FROM student, course
%% WHERE student.id = course.student_id GROUP BY student.name;
@@ -64,7 +64,6 @@ limit() ->
%% LEFT JOIN client ON client.group_id = `group`.id
%% GROUP BY `group`.id HAVING count(client.id) > 3;
%%
-%% Use having with:
%% AVG() - Returns the average value
%% COUNT() - Returns the number of rows
%% FIRST() - Returns the first value
@@ -75,7 +74,8 @@ limit() ->
having() ->
[ {G.name, G.id, CC}
|| G <- table(group),
- C <- join_table(client),
+ C <- table(client),
+ all(C),
CC = count(C.id),
group(G.id), C.group_id == G.id, CC > 3].
Please sign in to comment.
Something went wrong with that request. Please try again.