-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Queries with and/or operators not working (on Elixir 1.6) #70
Comments
I was just about to report this. In order to work around this, I had to modify my fork of Que and add some dirty hacks: https://github.com/AlloyCI/que/commit/593dc65c3405c0f5381a091ce2703c3401618485 AlloyCI really depends on this, so hoping this gets resolved soon, I don't want to rely on a dirty hack. |
This sounds like a bug in Elixir to me, looking into it. |
@meh while investigating the errors, it seemed to me that they might be coming from a bug in expanding the |
@supernova32 yeah, my suspicion is something changed slightly in the AST between 1.5 and 1.6, I just need to find the time to look into that, unless someone else beats me to it, this sounds like it shouldn't have happened. |
The issue is that exquisite is relying on a macro to expand to a certain format which is a no-no since Elixir can change what macro expands to at any moment. The way Ecto approaches this is by traversing the known nodes before expanding them. So for example, if you know how to handle the |
@josevalim actually now that I look into it a little more, it seems to have nothing to do with the AST. Using the following as example: from = {{2013,1,1},{1,1,1}}
to = {{2013,2,2},{1,1,1}}
s = Exquisite.match { a, b },
where: a >= from and b <= to,
select: 2 Elixir 1.5: {{:a, [line: 27], nil}, {:b, [line: 27], nil}}
[where: {:and, [line: 28],
[{:>=, [line: 28], [{:a, [line: 28], nil}, {:from, [line: 28], nil}]},
{:<=, [line: 28], [{:b, [line: 28], nil}, {:to, [line: 28], nil}]}]},
select: 2]
[{:{}, [],
[{:"$1", :"$2"},
[{:{}, [],
[:andalso,
{:{}, [],
[:>=, :"$1",
{{:., [], [{:__aliases__, [alias: false], [:Exquisite]}, :convert]}, []
[{:from, [line: 28], nil}]}]},
{:{}, [],
[:"=<", :"$2",
{{:., [], [{:__aliases__, [alias: false], [:Exquisite]}, :convert]}, []
[{:to, [line: 28], nil}]}]}]}], [2]]}] Elixir 1.6: {{:a, [line: 27], nil}, {:b, [line: 27], nil}}
[
where: {:and, [line: 28],
[
{:>=, [line: 28], [{:a, [line: 28], nil}, {:from, [line: 28], nil}]},
{:<=, [line: 28], [{:b, [line: 28], nil}, {:to, [line: 28], nil}]}
]},
select: 2
]
[
{:{}, [],
[
{:"$1", :"$2"},
[
{{:., [], [{:__aliases__, [alias: false], [:Exquisite]}, :convert]}, [],
[
{:case, [optimize_boolean: true],
[
{:>=, [line: 28],
[{:a, [line: 28], nil}, {:from, [line: 28], nil}]},
[
do: [
{:->, [],
[
[true],
{:<=, [line: 28],
[{:b, [line: 28], nil}, {:to, [line: 28], nil}]}
]},
{:->, [], [[false], false]},
{:->, [],
[
[{:other, [counter: -576460752303423484], Kernel}],
{{:., [], [:erlang, :error]}, [],
[
{{:., [],
[
{:__aliases__,
[alias: false, counter: -576460752303423484],
[:BadBooleanError]},
:exception
]}, [],
[
[
operator: :and,
term: {:other, [counter: -576460752303423484],
Kernel}
]
]}
]}
]}
]
]
]}
]}
],
[2]
]}
] I don't see any difference in the input (unless I'm blind) so it must be some change in macro expansion, did anything in |
Any Updates on this? |
Bump. Would really like to see this issue resolved soon. @meh @josevalim Is there anything I can do to get this fixed? What do you think the problem is here? |
I also have this issue occurring for me, sadly - same symptoms on elixir 1.6 e: also happy to help where I can |
FIY,
to
works for me |
@jonathanleang Do you have a work around for where-queries with |
Exactly. Before I had:
now.. I can't do it. I mean literally I can't get Amnesia to work on Elixir 1.7. It was just fine on 1.6. Amount of failures I got caused by CALLER or other stuff like this is staggering (exquisite as an example). I have to stay on Elixir 1.6 cause this is madness that I'm literally unable to fix my project now. With amount of incompatibilities Elixir 1.7 is causing.. I don't understand why it's not Elixir 2.0 instead - since there are plenty of MAJOR changes in language. |
I'm able to run Amnesia with and/or queries on Elixir 1.7.4, Erlang 21 using my patched version of exquisite. Patched Exquisite to handle and/or queries. In Deps: |
I actually just ended up writing my own wrapper around |
On Elixir 1.6.0,
where
statements withand
oror
operators cause compilation errors. Thewhere
macro works fine when they are not used, but when they are, for some reason elixir expands the match fields to functions (which don't exist), throwing a compilation error.Environment Details:
Reproducing the Issue:
A simple elixir application with
amnesia
set up, along with this DB/Table. This would not compile onElixir 1.6.0
, but if you remove thefind/2
method, it will.Error:
Everything else works as expected. This is a serious bug which also affects one of my projects; Que. Hoping this gets resolved soon!
The text was updated successfully, but these errors were encountered: