Skip to content

SQLite DATETIME does not convert to Date in query with aliases #3611

Closed

Description

@mikalai-ramashka

When using SQLite dialect, it appears that DATETIME field isn't decoded to Date object in query with aliases.

I have model defined as:

   createdAt: {
      type: DataTypes.DATE,
      field: 'created_at'
    },
    updatedAt: {
      type: DataTypes.DATE,
      field: 'updated_at'
    }
if (result.hasOwnProperty(name) && metaData.columnTypes[name]) {
  if (metaData.columnTypes[name] === 'DATETIME') {
    // we need to convert the timestamps into actual date objects
    var val = result[name];

    if (val !== null) {
      if (val.indexOf('+') === -1) {
        // For backwards compat. Dates inserted by sequelize < 2.0dev12 will not have a timestamp set
        result[name] = new Date(val + self.sequelize.options.timezone);
      } else {
        result[name] = new Date(val); // We already have a timezone stored in the string
      }
    }
  } else if (metaData.columnTypes[name].lastIndexOf('BLOB') !== -1) {
    if (result[name]) {
      result[name] = new Buffer(result[name]);
    }
  }
}

in query.js

I had in result createAt, updateAt, but in metaData.columnTypes definition for create_at column

Activity

  1. added
    type: bug
    dialect: sqlite
    on May 11, 2015
  2. added 3 commits that reference this issue on Jul 24, 2015
    00c6b5e
    6b719a7
    112612a
  3. added a commit that references this issue on Jul 31, 2015
    c0ff86f
  4. added 2 commits that reference this issue on Nov 9, 2015
    c076ba2
    484c0c2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    dialect: sqlitetype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions