You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for some reason the driver casts a number to a string?
schema:
CREATE EXTENSION pgcrypto;
CREATETABLEusers (
id SERIALNOT NULLPRIMARY KEY,
username TEXTNOT NULL UNIQUE,
password TEXTNOT NULL
);
CREATETABLEsessions (
id uuid NOT NULL DEFAULT GEN_RANDOM_UUID() PRIMARY KEY,
expires_at timestampNOT NULL DEFAULT NOW() + INTERVAL '1 day',
user_id intNOT NULLREFERENCES users(id) ON DELETE CASCADE
);
CREATE OR REPLACEFUNCTIONupdate_password(
p_userid INT,
p_new_password TEXT
) RETURNS TABLE(session_id uuid, expires_at timestamp) AS $$
DECLARE
v_user_id INT;
BEGINUPDATE users
SET password = crypt(p_new_password, gen_salt('bf'))
WHERE id = p_userid
RETURNING id INTO v_user_id;
IF NOT FOUND THEN
RAISE EXCEPTION 'User not found';
END IF;
DELETEFROM sessions WHERE user_id = v_user_id;
INSERT INTO sessions (user_id)
VALUES (v_user_id)
RETURNING id, sessions.expires_at INTO session_id, expires_at;
RETURN NEXT;
END;
$$ LANGUAGE plpgsql;
query:
awaitsql`SELECT * FROM update_password(${38},${"new password"})`
error:
Uncaught PostgresError: operator does not exist: integer = text
at ErrorResponse (file:///home/angst/dev/links/node_modules/postgres/src/connection.js:788:26)
at handle (file:///home/angst/dev/links/node_modules/postgres/src/connection.js:474:6)
at Socket.data (file:///home/angst/dev/links/node_modules/postgres/src/connection.js:315:9)
at Socket.emit (node:events:518:28)
at Socket.emit (node:domain:552:15)
at addChunk (node:internal/streams/readable:561:12)
at readableAddChunkPushByteMode (node:internal/streams/readable:512:3)
at Readable.push (node:internal/streams/readable:392:5)
at TCP.onStreamRead (node:internal/stream_base_commons:191:23)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
at cachedError (file:///home/angst/dev/links/node_modules/postgres/src/query.js:170:23)
at new Query (file:///home/angst/dev/links/node_modules/postgres/src/query.js:36:24)
at sql (file:///home/angst/dev/links/node_modules/postgres/src/index.js:112:11)
at REPL25:1:40 {
severity_local: 'ERROR',
severity: 'ERROR',
code: '42883',
hint: 'No operator matches the given name and argument types. You might need to add explicit type casts.',
where: 'PL/pgSQL function update_password(text,text) line 6 at SQL statement',
internal_position: '84',
internal_query: 'UPDATE users\n' +
" SET password = crypt(p_new_password, gen_salt('bf'))\n" +
' WHERE id = p_userid\n' +
' RETURNING id',
file: 'parse_oper.c',
line: '635',
routine: 'op_error'
}
if i run same query via psql it works fine..
SELECT*FROM update_password(38,'newpass');
The text was updated successfully, but these errors were encountered:
for some reason the driver casts a number to a string?
schema:
query:
error:
if i run same query via psql it works fine..
The text was updated successfully, but these errors were encountered: