Skip to content

inserting string data into int column fails silently #18

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kkaefer opened this issue Mar 2, 2011 · 2 comments
Closed

inserting string data into int column fails silently #18

kkaefer opened this issue Mar 2, 2011 · 2 comments

Comments

@kkaefer
Copy link

kkaefer commented Mar 2, 2011

z, x, y are int columns:

var pg = require('pg');

var credentials = 'pg://demo@localhost/logs';

var client = new pg.Client(credentials);
client.connect();

client.query("INSERT INTO requests (api, name, z, y, x, type) " +
    "VALUES ($1, $2, $3, $4, $5, $6)",
    [ '1.0.0', 'foo', '35', '5', '2', 'png' ],
    function(err) {
        console.log(err);
    });
@brianc
Copy link
Owner

brianc commented Mar 2, 2011

does the data not get inserted? When I test this:

var pg = require(__dirname + '/../node-postgres/lib');
pg.connect("tcp://postgres:1234@localhost/postgres", Æ(err, client) {
  client.query("CREATE TEMP TABLE test(num integer)");
  client.query("INSERT INTO test(num) VALUES($1)", ['1'], Æ(err, result) {
    console.log("error: %j", err);
    console.log("result: %j", result);
  })
})

I get the output:

$ node spike/insert-tests.js
error: null
result: {"rows":[],"command":"INSERT","rowCount":1,"oid":0}

@kkaefer
Copy link
Author

kkaefer commented Mar 2, 2011

Sorry for that; I suspect it didn't get inserted because the surrounding transaction was cancelled.

brianc pushed a commit that referenced this issue Apr 28, 2020
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants