dresende / node-orm2

Object Relational Mapping
http://github.com/dresende/node-orm2
MIT License
3.07k stars 379 forks source link

FIX timezone bug in sqlite:issue #820 #822

Closed moonrailgun closed 6 years ago

moonrailgun commented 6 years ago

sample test js script

var orm = require('orm');
var path = require('path');

// orm.connect("sqlite://" + path.resolve(process.cwd(), './database.db?timezone=+08:00'), function(err, db) {
orm.connect("sqlite://" + path.resolve(process.cwd(), './database.db'), function(err, db) {
  if (err) throw err;

  var Person = db.define("person", {
        uuid: {type: 'text', required: false},
        date: {type: 'date',time: true},
    });
  console.log('current date:', new Date());
  console.log('------');
  db.sync(function() {
    Person.create({
      uuid: 1,
      date: new Date()
    }, (err, p) => {
      console.log(JSON.stringify(p));// data from memory
      console.log('------');

      Person.get(p.id, function(err, d) {
        console.log(JSON.stringify(d));// data from sqlite file
      })
    })
  })
})
dxg commented 6 years ago

Looks good, can you please add a test?

moonrailgun commented 6 years ago

Test suit have been added, thanks for review

dxg commented 6 years ago

Thanks. I've published 4.0.2 with the fix.

moonrailgun commented 6 years ago

Welcome