I'm having problems running a query that works directly in psql with postgis extension but not with the javascrip pg library connection within a prepared statement.
The query that runs and writes in the database is as follows:
INSERT INTO waps(bssid, strength, "location")
VALUES('T_601', '100', ST_GeomFromText('POINT(38.70722651513132, -9.15248591105515)', 4326));
The table waps has the location column as geometry type.
In my college javascript project I have this section of code returning an error:
let sql = "INSERT INTO waps (bssid, strength, location) VALUES($1,$2, ST_GeomFromText(POINT($3),4326)) RETURNING id";
let wapId = await pool.query(sql, [bssid, strenght, location]);
location receives ex: "38.70722651513132, -9.15248591105515", and returns an error:
{ error: function point(unknown) is not uniqueupLog Completed in 2ms
at Parser.parseErrorMessage (project/node_modules/pg-protocol/dist/parser.js:287:98)
at Parser.handlePacket (project/node_modules/pg-protocol/dist/parser.js:126:29)
at Parser.parse (project/node_modules/pg-protocol/dist/parser.js:39:38)
at Socket.stream.on (project/node_modules/pg-protocol/dist/index.js:11:42)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
length: 195,
name: 'error',
severity: 'ERROR',
code: '42725',
detail: undefined,
casts.',
position: '76',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'parse_func.c',
line: '572',
routine: 'ParseFuncOrColumn' }
So why does the query in psql runs normally but when prepared in a javascript environment throws an error?
The problem lies, normally, between the screen and the chair, so any help is appreciated.