You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically if the "pk" key is not one of "int", "uuid", etc, an error is thrown in the code (adapter-IndexedBD line 117) but it never reach the the top-level call. This means that neither then or catch is called after the exec.
This is (mostly) expected behavior. You can set whatever valued you'd like for the primary key (in practice it's reduced to a string or number, though). You can set whatever type you'd like as the primary key and nanoSQL will work just fine, for example I'll often set a primary key as a string type and provide manually generated keys based on how I want the data to be organized.
The problem happens when you provide a primary key type that can't be auto generated AND you fail to provide a primary key, I already had throw new Error blocks in the code for these situations, but they weren't bubbling up to the query promise.
1.7.0 has changed this, the query errors will now bubble up to the promise so you get better feedback on things. Hope that gets it working how you expect!
I spent like 1 hour finding out why it was "not working". I mean, I executed, reviewed things over and over, the DB was not been modified... so I started to follow up the internal code of nanoSQL till I found I made a stupid copy-and-paste error. Thank you again!
I have it in a codepen.
Basically if the "pk" key is not one of "int", "uuid", etc, an error is thrown in the code (adapter-IndexedBD line 117) but it never reach the the top-level call. This means that neither then or catch is called after the exec.
nSQL("testing")
.model([
{key: "id", type: "string", props: ["pk"]},
{key: "title", type: "string"}
])
.connect().then(() => {
console.log( 'I pass by here' ) ;
return nSQL().query("upsert", {title:'hello world'}).exec();
}).then((rows) => {
console.log('rowsss', rows);
}).catch( error => {
console.log( 'error', error ) ;
})
console.log( 'ERROR: if the type of the ai key is string, then no error is thrown')
https://codepen.io/anon/pen/yEqvXb?editors=0011
The text was updated successfully, but these errors were encountered: