null+****@clear*****
null+****@clear*****
2012年 7月 31日 (火) 11:18:13 JST
Yoji SHIDARA 2012-07-31 11:18:13 +0900 (Tue, 31 Jul 2012) New Revision: 321917281545aa1fc2854a6f44490935a6583aea https://github.com/nroonga/nroonga/commit/321917281545aa1fc2854a6f44490935a6583aea Log: Ignore null valued arguments Modified files: lib/nroonga.js src/nroonga.coffee test/database.test.coffee Modified: lib/nroonga.js (+4 -2) =================================================================== --- lib/nroonga.js 2012-07-17 15:42:59 +0900 (6ece3ae) +++ lib/nroonga.js 2012-07-31 11:18:13 +0900 (cd724cb) @@ -12,8 +12,10 @@ if (options != null) { for (key in options) { value = options[key]; - args.push('--' + key); - args.push(JSON.stringify(value)); + if (value != null) { + args.push('--' + key); + args.push(JSON.stringify(value)); + } } } return args.join(' '); Modified: src/nroonga.coffee (+3 -2) =================================================================== --- src/nroonga.coffee 2012-07-17 15:42:59 +0900 (b7d620e) +++ src/nroonga.coffee 2012-07-31 11:18:13 +0900 (839b2c5) @@ -5,8 +5,9 @@ optionsToCommandString = (command, options) -> args = [command] if options? for key, value of options - args.push '--' + key - args.push JSON.stringify(value) + if value? + args.push '--' + key + args.push JSON.stringify(value) args.join(' ') overrideOutputType = (optionsGiven, type) -> Modified: test/database.test.coffee (+6 -0) =================================================================== --- test/database.test.coffee 2012-07-17 15:42:59 +0900 (9469d59) +++ test/database.test.coffee 2012-07-31 11:18:13 +0900 (bff0a2e) @@ -117,6 +117,12 @@ describe 'database with data stored', -> matched[0][0][0].should.equal(3) done() + it 'should select records ignoring the null valued option', (done) -> + withTestDatabase (db) -> + matched = db.commandSync('select', table: 'Site', query: null) + matched[0][0][0].should.equal(3) + done() + it 'should search by query', (done) -> withTestDatabase (db) -> matched = db.commandSync 'select', -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...下载