Odinakachukwu Omaka-chukwu
10/25/2024, 4:03 PMcreate:
INSERT INTO user_account(username, password)
VALUES (:username, crypt(:password, gen_salt('bf', 8)));
but I'm getting this error
Cannot bind unknown types or null
I've installed the required extensions and the function works without parameters, but it seems like it cant infer the password type. How do I go about thisOdinakachukwu Omaka-chukwu
10/25/2024, 4:28 PMcreate:
INSERT INTO user_account(username, password)
VALUES (:username, crypt(COALESCE(:password,''), gen_salt('bf', 8)));
griffio
10/25/2024, 4:47 PMpgcrypto
extension functions
SqlDelight doesn’t know about extensions functions that you add manually as there are too many
You can see here for an example https://github.com/griffio/sqldelight-custom-dialect of how to add functions
In your case, if need it, you can add to the custom resolver - if you have it working somehow already then it’s probably too much bother
"crypt" -> IntermediateType(PrimitiveType.TEXT)
"gen_salt" -> IntermediateType(PrimitiveType.TEXT)
Your .sq
file would look like
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE TABLE IF NOT EXISTS user_account (username TEXT, password TEXT);
create:
INSERT INTO user_account(username, password)
VALUES (:username, crypt(:password, gen_salt('bf', 8)));
Odinakachukwu Omaka-chukwu
10/25/2024, 4:58 PM