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

revert adding placetype column #79

Merged
merged 1 commit into from
Nov 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions lib/TokenIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ TokenIndex.prototype.reset = function(){
this.db.exec('CREATE INDEX IF NOT EXISTS lineage_cover_idx ON lineage(id, pid);');

this.db.exec('DROP TABLE IF EXISTS tokens;');
this.db.exec('CREATE TABLE tokens( id INTEGER, layer STRING, lang STRING, tag STRING, token STRING );');
this.db.exec('CREATE INDEX IF NOT EXISTS tokens_cover_idx ON tokens(id, layer, lang, tag);');
this.db.exec('CREATE TABLE tokens( id INTEGER, lang STRING, tag STRING, token STRING );');
this.db.exec('CREATE INDEX IF NOT EXISTS tokens_cover_idx ON tokens(id, lang, tag);');
this.db.exec('CREATE INDEX IF NOT EXISTS tokens_token_idx ON tokens(token);');

// FTS table options
Expand All @@ -41,10 +41,9 @@ TokenIndex.prototype.checkSchema = function(){
]);
Database.assertSchema(this.db, 'tokens', [
{ cid: 0, name: 'id', type: 'INTEGER', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 1, name: 'layer', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 2, name: 'lang', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 3, name: 'tag', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 4, name: 'token', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 }
{ cid: 1, name: 'lang', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 2, name: 'tag', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 3, name: 'token', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 }
]);
Database.assertSchema(this.db, 'fulltext', [
{ cid: 0, name: 'token', type: '', notnull: 0, dflt_value: null, pk: 0 }
Expand Down Expand Up @@ -77,13 +76,12 @@ TokenIndex.prototype.setTokens = function( id, tokens, cb ){

// create prepared statement
var stmt = this.prepare(
'INSERT INTO tokens ( id, layer, lang, tag, token ) VALUES ( $id, $layer, $lang, $tag, $token )'
'INSERT INTO tokens ( id, lang, tag, token ) VALUES ( $id, $lang, $tag, $token )'
);

try {
tokens.forEach( token => stmt.run({
id: id,
layer: token.layer,
lang: token.lang,
tag: token.tag,
token: token.body
Expand Down
11 changes: 5 additions & 6 deletions test/lib/TokenIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@ module.exports.reset = function(test, common) {
sql = 'PRAGMA table_info(tokens)';
t.deepEqual( db.prepare(sql).all(), [
{ cid: 0, name: 'id', type: 'INTEGER', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 1, name: 'layer', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 2, name: 'lang', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 3, name: 'tag', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 4, name: 'token', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 }
{ cid: 1, name: 'lang', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 2, name: 'tag', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 },
{ cid: 3, name: 'token', type: 'STRING', notnull: 0, dflt_value: null, pk: 0 }
]);

// ensure table has been created
Expand Down Expand Up @@ -176,8 +175,8 @@ module.exports.setTokens = function(test, common) {
// ensure rows have been created
const sql = 'SELECT * FROM tokens';
t.deepEqual( db.prepare(sql).all(), [
{ id: 100, layer: null, lang: 'en', tag: 'abbr', token: 'test1' },
{ id: 100, layer: null, lang: 'fr', tag: 'variant', token: 'test2' }
{ id: 100, lang: 'en', tag: 'abbr', token: 'test1' },
{ id: 100, lang: 'fr', tag: 'variant', token: 'test2' }
]);

});
Expand Down