question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Invalid input syntax for type timestamp with time zone" on insert/update, postgreSQL

See original GitHub issue

I’m unable to use the hasTimestamps successfully and not sure why. I’m also using Bookshelf, but I think the problem is at the knex level.

From my initial migration script:

exports.up = function(knex, Promise) {
  return Promise.all(
    [ knex.schema.createTable('whatevers', function (table) {
        table.uuid('id').primary();
        // snip
        table.timestamps();
      })
    ]
  );
};

From my bookshelf.js model definition:

WhateverModel =
{ tableName: 'whatevers'
, hasTimestamps: true
, defaults: function () {
    var d =
        { id: uuid.v1()
        }
    ;

    return d;
  }
};

The error I get on Insert or Update is:

error { [error: invalid input syntax for type timestamp with time zone: "{}"]
  name: 'error',
  length: 119,
  severity: 'ERROR',
  code: '22007',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  file: 'datetime.c',
  line: '3567',
  routine: 'DateTimeParseError' }

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
jmhnilbogcommented, Nov 10, 2014

Yes, looks like a bad library choice on my part. ‘snakeize’ was turning my Date objects into bare objects in my model’s format() function.

0reactions
jmhnilbogcommented, Dec 18, 2018

@brunolm No clue what I ended up doing. This was three jobs ago! My guess is that I monkey-patched things and kept moving. (I recall this app growing an appendix of monkey-patches, as we locked down dependencies pretty early in development. Relying on npm and accurate semver was a lot sketchier in 2014.

Read more comments on GitHub >

github_iconTop Results From Across the Web

[22007] ERROR: invalid input syntax for type timestamp ...
Have you tried casting your WHERE clause: WHERE cast(foo.valueTS AS TIMESTAMP) <= now();. Also have you tried using CURRENT_TIMESTAMP ...
Read more >
ERROR: invalid input syntax for type timestamp with time zone
(timestamptz_in() -> DecodeDateTime()). But when I tried to enter same date with other format then it does work.
Read more >
Thread: invalid input syntax for type timestamp.
Hi. I was doing the field test of Slony-I 1.2.2 release now. However, I encounter the problem of timestamp.:-( Was anyone recognizing this...
Read more >
T31392 PostgreSQL invalid input syntax for type timestamp ...
Changing the timestamp type in ApiBase.php is a bad idea. Changing it to TS_POSTGRES is even worse, because that'll break on non-Postgres backends....
Read more >
invalid input syntax for type timestamp with time zone #301
pg_partman currently only works with the data type timestamp with time zone . Unless you have a very specific need for timestamp without...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found