Repository navigation
Closed
Description
AlaSQL is based on unpaid voluntary work. Thank you for taking the time to make it better.
Question about how to ...
Something is not working as expected:
-
Describe the problem
UNION does not work.
-
Provide code that replicates the problem
data1=[{a:'abc'},{a:'xyz'}]
data2=[{a:'123'},{a:'987'}]
alasql("select * from :a union select * from :b",{a:data1,b:data2})
--- FF 95.01 Linux
[
{},
{},
{
"a": "abc"
},
{
"a": "xyz"
}
]
alasql.version
"1.7.3-develop-0be167bcundefined"
----- Chrome 97.0 Linux
[
{},
{},
{
"a": "abc"
},
{
"a": "xyz"
}
]
alasql.version
'1.7.3-develop-0be167bcundefined'
---- Node
> data1=[{a:'abc'},{a:'xyz'}]
[ { a: 'abc' }, { a: 'xyz' } ]
> data2=[{a:'123'},{a:'987'}]
[ { a: '123' }, { a: '987' } ]
>
> alasql("select * from :a union select * from :b",{a:data1,b:data2})
[ {}, {}, { a: 'abc' }, { a: 'xyz' } ]
> alasql.version
'1.7.3-develop-0be167bcundefined'
---- How does it work in sqlite3
sqlite> create table one(a text);
sqlite> create table two(a text);
sqlite> insert into a values('abc'),('def');
sqlite> insert into two values('xyz'),('123');
sqlite> select * from one union select * from two;
123
abc
def
xyz
- We suggest to spawn a jsfiddle from http://jsfiddle.net/98qL7m0c/
Maybe I'm using alasql incorrectly? I tried looking at some documentation in the wiki but the section on union is quite spartan.
Anyway, thanks a lot!
Activity
mathiasrw commentedon Sep 24, 2022
It should work - but does not...
Tisamu commentedon Oct 13, 2022
I would like to take the issue, could it be assigned to me ? 👍
( Here is a correct jsfiddle relative to this issue btw : http://jsfiddle.net/7pdhe9ng/ )
Thanks !
mathiasrw commentedon Oct 14, 2022
Sure!
mathiasrw commentedon Oct 26, 2022
@Tisamu Any ideas on how to approach this issue?
Tisamu commentedon Oct 26, 2022
Hello, sorry for giving no news.
Yep I've debugged a bit and it seems that the params of the first table are not passed to the union compilation method.
I'm still trying to understand all the compilation process of the query so I'm not sure where is the problem precisely.
I'm gonna work more on it this weekend. 😄
mathiasrw commentedon Oct 27, 2022
I have not dived into where this might be - but a few hints to debug: Its often good to understand the compiled function that is constructed to execute the query.
Idea:
Replicate the problem in the CLI version of alasql.
In the file
dist/alasql.fs.js>THIS FILE WILL BE OVERWRITTEN IF YOUyarn buildORyarn test!< you find where the compiled function to be executed is created.It could be here forexample
Then you run your CLI command with the inspect flag
Then you open chrome and go to
chrome://inspect/#devicesand click "inspect"Now click here to start running
Then - if you placed the
debugger;correctly you can inspect and follow what is happening. Happy hunting.(nope - the place I inserted the
debugger;did not stop the execution meaning that its not the right place...)Please remember to move any changes to the proper files in src/ folder. Too many times have I found a fix and forgot I was live editing in the build destination and had to redo the details.
Tisamu commentedon Oct 27, 2022
Nice ! Thanks for the tips. 😄
[-]Problems with the UNION :)[/-][+]UNION not returning correct result[/+]Tisamu commentedon Nov 3, 2022
Well, sorry but I've a bit busy those weeks, not sure if I will be able to fix it soon.☹️
Feel free to un-assign me the issue if someone else wanna take it.
mathiasrw commentedon Nov 3, 2022
Thank you for leaning in. Let me know if you leant something you want to share with others.
mathiasrw commentedon Dec 27, 2022
Any luck @Tisamu ?
add test for issue AlaSQL#1415
fix AlaSQL#1415: UNION not returning correct result (AlaSQL#1629)