Open yuyudhan opened 8 years ago
Hello yuyudhan,
Did you ever figure this out?
No @daschewie , did not try this since long, did not find any solution to it.
It seems no body care about this program
I investigate this issue in deep.
Sqlite3 has a built-in feature for retrieving the lastID on INSERT statement.
It's use here https://github.com/strongloop-community/loopback-connector-sqlite3/blob/master/lib/sqlite3.js#L202
But in the documentation of Sqlite3 https://sqlite.org/c3ref/last_insert_rowid.html the lastID contains the last rowid inserted but when your primary key is not integer you have two primary key : the primary key define in schema and the sqlite3 internal rowid.
So when we have on INSERT the lastID=an interger and the real id
the token which is override by the dao https://github.com/strongloop/loopback-datasource-juggler/blob/master/lib/dao.js#L410.
A solution would be to add WITHOUT ROWID
option an the CREATE TABLE for the AccessToken
and other model with a string primary key.
For that we need to add model options for this connector. I will start to write a PR this afternoon.
EDIT: WITHOUT ROWID
does not solve issue because it returns the last ID inserted on all tables.
My #38 Solve the issue ;-) You can test my PR in your project
"dependencies": {
"loopback-connector-sqlite3": "git+https://github.com/HugoPoi/loopback-connector-sqlite3.git#faf96a0"
}
But need a review from the admin team. And a release.
Sqlite3 connector gives following when logging in: Access token stored in the database is correct, but returned id is the id of accessToken instead of the token itself.
When using db(in-memory) for storing access tokens it gives following correct result.