Skip to content
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

Issue with select left join from field columns #161

Closed
azhai2016 opened this issue Aug 7, 2019 · 1 comment
Closed

Issue with select left join from field columns #161

azhai2016 opened this issue Aug 7, 2019 · 1 comment
Labels

Comments

@azhai2016
Copy link

nSQL().createDatabase({
id: "my-db",
mode: "TEMP", // pass in "PERM" to switch to persistent storage mode!
tables: [
{
name: "users",
model: {
// pk == primary key, ai == auto incriment,
"id:int": {pk: true, ai: true},
"name:string": {},
"age:int":{}
}
},
{
name: "users1",
model: {
// pk == primary key, ai == auto incriment,
"id:int": {pk: true, ai: true},
"name:string": {},
"age:int":{}
}
},
]
})
.then(function() {
// Add a record
nSQL("users1").query('upsert',{
name:"aaa", age: 10
}).exec();

return nSQL("users").query('upsert',{
    name:"aaa", age: 20
}).exec();

})
.then(function(result) {
// select all rows
return nSQL()
.query('select',["users1.name AS aaa"])
.join({
type:"left",
with:{table:"users1"},
on:["users.name","=","users1.name"]
}).exec();
})
.then(function(result) {
var elem = document.createElement("pre");
document.body.appendChild(elem);
elem.innerHTML = JSON.stringify(result, null, 4)
})

result:
[
{
"aaa.0": "a",
"aaa.1": "a",
"aaa.2": "a"
}
]

@azhai2016 azhai2016 changed the title Join select from columns issue Issue with select left Join from columns Aug 7, 2019
@azhai2016 azhai2016 changed the title Issue with select left Join from columns Issue with select left join from columns Aug 7, 2019
@azhai2016 azhai2016 changed the title Issue with select left join from columns Issue with select left join from field columns Aug 7, 2019
only-cliches pushed a commit that referenced this issue Aug 12, 2019
@only-cliches
Copy link
Owner

This has been resolved in 2.3.6

defr0std added a commit to defr0std/Nano-SQL that referenced this issue Sep 16, 2020
And adding dist to sources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants