-
Notifications
You must be signed in to change notification settings - Fork 301
Reverse transform of column names when inserting or updating #16
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
Comments
Hi @davojan .. Yes I have considered an option for that.. Good to track in this issue - thanks ;) |
I like the non breaking way you suggested of supplying an object with |
It would be useful! |
Should we also transform column name for user can use it also useful for typescript I guess, we can restrict column name to |
@porsager Hey! Need this one badly. Has anyone worked on this? Are you open towards the PR? P.S. Also love the idea with |
this could be extremely useful. |
Hello, Thank you, I think it's fine: CREATE TABLE IF NOT EXISTS public."camelTable"
(
snake_to_camel text COLLATE pg_catalog."default"
) async function dooo() {
const importantInformation = {
snakeToCamel: "aaaa",
};
const importantColumns = ["snakeToCamel"];
const a_insert = await sql`
INSERT INTO "camelTable" ${sql(importantInformation)}
`;
const b_select = await sql`
SELECT ${sql(importantColumns)} FROM "camelTable"
`;
console.log(a_insert);
console.log(b_select);
} INSERT INTO "camelTable" ("snake_to_camel") values ($1)
[{"type":0,"value":"aaaa","raw":"aaaa"}]
SELECT "snake_to_camel" FROM "camelTable"
[
count: 1,
command: 'INSERT',
state: { status: 'I', pid: 1634864, secret: 1829386482 }
]
[
{ snakeToCamel: 'aaaa' },
{ snakeToCamel: 'aaaa' },
columns: [ { name: 'snakeToCamel', parser: undefined, type: 25 } ],
] |
Fixed with #212 |
Transforming column names in both ways would greatly improved ergonomics of the library. Consider this example:
Transform option should work both ways, I think. May be configured like this:
The text was updated successfully, but these errors were encountered: