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

No error is thrown if the primary key has none of the expected types #59

ditiem opened this issue Jun 25, 2018 · 3 comments


None yet
2 participants
Copy link

commented Jun 25, 2018

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.

{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')

@ClickSimply ClickSimply added the bug label Jul 3, 2018


This comment has been minimized.

Copy link

commented Jul 3, 2018

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!


This comment has been minimized.

Copy link

commented Jul 3, 2018

Thank you a lot Scott!

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!


This comment has been minimized.

Copy link

commented Jul 3, 2018

Sweet! Closing this issue, feel free to comment again if it comes back up. 👍

@ClickSimply ClickSimply closed this Jul 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.