Using Mnesia recently, I am trying to move from match_spec to qlc queries in order to query multiple tables at once. I am facing an error trying to apply qualifiers for filtering my results :
require Qlc
defmodule TestSchema do
defstruct id: nil, field: nil
end
:mnesia.start()
:mnesia.create_table(:test, [
ram_copies: [node()],
record_name: TestSchema,
attributes: [:id, :field],
type: :ordered_set
])
Qlc.q("[A || A <- mnesia:table('test'), A#'TestSchema'.field == \"field 2\"]", [])
# => ** (MatchError) no match of right hand side value: {:not_ok, [error: {1, :erl_lint, {:undefined_record, :TestSchema}}]}
# (qlc) lib/qlc.ex:183: Qlc.expr_to_handle/3
Is the syntax right ?
I a possible solution may be to declare Erlang record, Record.defrecord/2 only provide utilities to manipulate such type.
any clues ?






















