Skip to content

Commit

Permalink
Merge pull request #79 from pelias/revert_adding_placetype_column
Browse files Browse the repository at this point in the history
revert adding placetype column
  • Loading branch information
missinglink authored Nov 21, 2017
2 parents d1f2a95 + 716f44b commit 78bb5b6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
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

0 comments on commit 78bb5b6

Please sign in to comment.