balderdashy / balderdashy/sails

error: column "temp" does not exist, hint: 'There is a column named "temp" in table "temp", but it cannot be referenced from this part of the query.',

Open
#7,007 2 comments 0 reactions 0 assignees View on GitHub
help wanted more info please orm
Dominant language
JavaScript
Stars
22.8k
Forks
1.9k
PR merge metrics
No merged PRs in 30d

Description

var mqtt = require('mqtt')
var client = mqtt.connect('mqtt://localhost')
const Pool = require('pg');
const cs = 'postgres://postgres:Password@123@localhost:5432/temp';
const pool= new Pool.Client(cs);
pool.connect();

temp=0
hum=0

client.on('connect', () => {
client.subscribe('esp/dht/temperature',{qos:1}); console.log('client has subscribed Temp successfully');
client.subscribe('esp/dht/humidity',{qos:1}); console.log('client has subscribed humidity successfully');})

client.on('message', (topic, message) => {
if (topic === 'esp/dht/temperature') {
temp = message.toString();
}

if (topic === 'esp/dht/humidity') {
hum = message.toString();
}
console.log('Temperature:-',temp,'Humidity:-',hum)

})

//const query= 'INSERT INTO temp(temp,hum) VALUES (temp,hum)';
pool.query(
"INSERT INTO temp(temp,hum)VALUES(temp,hum)",
(err, res) => {
console.log(err, res);
pool.end();
}
);

returns error

{ error: column "temp" does not exist
at Parser.parseErrorMessage (/root/psql/node_modules/pg-protocol/dist/parser.js:241:15)
at Parser.handlePacket (/root/psql/node_modules/pg-protocol/dist/parser.js:89:29)
at Parser.parse (/root/psql/node_modules/pg-protocol/dist/parser.js:41:38)
at Socket.stream.on (/root/psql/node_modules/pg-protocol/dist/index.js:8:42)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
at addChunk (_stream_readable.js:263:12)
at readableAddChunk (_stream_readable.js:250:11)
at Socket.Readable.push (_stream_readable.js:208:10)
at TCP.onread (net.js:607:20)
length: 210,
name: 'error',
severity: 'ERROR',
code: '42703',
detail: undefined,
hint: 'There is a column named "temp" in table "temp", but it cannot be referenced from this part of the query.',
position: '34',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_relation.c',
line: '3293',
routine: 'errorMissingColumn' } undefined

Contributor guide

Open the contributing guide

Research direction

The only entry point shown is the Node.js snippet, especially the pool.query INSERT statement and the PostgreSQL error at /root/psql/node_modules/pg-protocol/dist/parser.js. Start by checking how the INSERT obtains its values and compare that with PostgreSQL's reported position 34. Done means the temperature and humidity readings are inserted without the reported column-reference error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, postgresql
Domain
databases
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.