loopbackio / loopback-connector-sqlite3

SQLite3 Connector for LoopBack
Other
13 stars 22 forks source link

Fix date parsing/validity check #2

Open kraman opened 9 years ago

kraman commented 9 years ago

The tests are passing on CI, but this is in the console:

Deprecation warning: moment construction falls back to js Date. This is discouraged and will be removed in upcoming major release. Please refer to https://github.com/moment/moment/issues/1407 for more info.
Error
    at deprecate (/Users/ryan/work/loopback-connector-sqlite3/node_modules/moment/moment.js:738:42)
    at /Users/ryan/work/loopback-connector-sqlite3/node_modules/moment/moment.js:826:50
    at /Users/ryan/work/loopback-connector-sqlite3/node_modules/moment/moment.js:8:85
    at Object.<anonymous> (/Users/ryan/work/loopback-connector-sqlite3/node_modules/moment/moment.js:11:2)
    at Module._compile (module.js:428:26)
    at Object.Module._extensions..js (module.js:446:10)
    at Module.load (module.js:353:32)
    at Function.Module._load (module.js:308:12)
    at Module.require (module.js:363:17)
    at require (module.js:382:17)
    at Object.<anonymous> (/Users/ryan/work/loopback-connector-sqlite3/lib/sqlite3.js:10:14)
    at Module._compile (module.js:428:26)
    at Object.Module._extensions..js (module.js:446:10)
    at Module.load (module.js:353:32)
    at Function.Module._load (module.js:308:12)
    at Module.require (module.js:363:17)
    at require (module.js:382:17)
    at Object.<anonymous> (/Users/ryan/work/loopback-connector-sqlite3/index.js:1:80)
    at Module._compile (module.js:428:26)
    at Object.Module._extensions..js (module.js:446:10)
    at Module.load (module.js:353:32)
    at Function.Module._load (module.js:308:12)
    at Module.require (module.js:363:17)
    at require (module.js:382:17)
    at global.getDataSource.global.getSchema (/Users/ryan/work/loopback-connector-sqlite3/test/init.js:6:27)
    at Context.<anonymous> (/Users/ryan/work/loopback-connector-sqlite3/test/sqlite.dbdefaults.test.js:10:10)
    at callFn (/Users/ryan/work/loopback-connector-sqlite3/node_modules/mocha/lib/runnable.js:266:21)
    at Hook.Runnable.run (/Users/ryan/work/loopback-connector-sqlite3/node_modules/mocha/lib/runnable.js:259:7)
    at next (/Users/ryan/work/loopback-connector-sqlite3/node_modules/mocha/lib/runner.js:271:10)
    at Immediate._onImmediate (/Users/ryan/work/loopback-connector-sqlite3/node_modules/mocha/lib/runner.js:292:5)
    at processImmediate [as _immediateCallback] (timers.js:371:17)
[Error: Invalid date default: '5']

edit: replaced deprecation with output from a non-coverage run of npm test

kraman commented 9 years ago

/cc @rmg

rmg commented 9 years ago

Looking into this, it seems that using moment() for parsing arbitrary dates is actually no better than just using Date.parse().

In the processes of switching to a combination of Date.parse() and isNaN() checks on the result, I happened to discovered a bug.

rmg commented 9 years ago

Added comments on the initial PR - easier to reference this issue there and have them show up here than generate links to the relevant lines.