Hi, someone have some Erlang qlc join examples? i’m trying merge two tables but result data is duplicated. i write this qlc:
disk_partitions() ->
mnesia:transaction(
fun() ->
qlc:eval(
qlc:q([
{D0, D1, D2, D3, P, D5, D6} ||
{D0, D1, D2, D3, _D4, D5, D6} <- mnesia:table(disk),
P = {_P0, P1, _P2, _P3, _P4, _P5, _P6, _P7} <- mnesia:table(partition),
D1 =:= re:replace(P1, "[0-9]+", "", [{return, binary}])
])
)
end
).
and returned this:
iex(43)> :join_queries.disk_partitions
{:atomic,
[
{:disk, "/dev/sdb", "101 GT", "dos",
{:partition, "/dev/sdb1", [], "Test", true, "/some/fake/path", "fat32",
"UU82-3O93"}, "AB87-3S21", "TOSHIBA"},
{:disk, "/dev/sdb", "101 GT", "dos",
{:partition, "/dev/sdb2", [], "2Record", false, "fake_point", "exfat",
"som2_3de2"}, "AB87-3S21", "TOSHIBA"}
]}
i want some like this
{:atomic,
[
{:disk, "/dev/sdb", "101 GT", "dos",
[{:partition, "/dev/sdb1", [], "Test", true, "/some/fake/path", "fat32",
"UU82-3O93"}, {:partition, "/dev/sdb2", [], "2Record", false, "fake_point", "exfat", "som2_3de2"}] "AB87-3S21", "TOSHIBA"}
]}
when i tried adding {join, merge} i got the error:
iex(9)> :join_queries.disk_partitions
{:aborted,
{:no_join_to_carry_out,
[
{:qlc, :check_join_option, [join: :merge], [file: 'qlc.erl', line: 2202]},
{:qlc, :prep_join, 3, [file: 'qlc.erl', line: 2062]},
{:qlc, :prepare_qlc, 7, [file: 'qlc.erl', line: 1672]},
{:qlc, :eval, 2, [file: 'qlc.erl', line: 293]},
{:mnesia_tm, :apply_fun, 3, [file: 'mnesia_tm.erl', line: 842]},
{:mnesia_tm, :execute_transaction, 5, [file: 'mnesia_tm.erl', line: 818]},
{:erl_eval, :do_apply, 6, [file: 'erl_eval.erl', line: 685]},
{:elixir, :recur_eval, 3, [file: 'src/elixir.erl', line: 280]},
{:elixir, :eval_forms, 3, [file: 'src/elixir.erl', line: 265]},
{IEx.Evaluator, :handle_eval, 3, [file: 'lib/iex/evaluator.ex', line: 298]},
{IEx.Evaluator, :do_eval, 3, [file: 'lib/iex/evaluator.ex', line: 274]},
{IEx.Evaluator, :eval, 3, [file: 'lib/iex/evaluator.ex', line: 263]},
{IEx.Evaluator, :loop, 1, [file: 'lib/iex/evaluator.ex', line: 157]},
{IEx.Evaluator, :init, 4, [file: 'lib/iex/evaluator.ex', line: 32]},
{:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 226]}
]}}
i readed erlang docs but idk how can i make to work the qlc joins.
Thanks.