Is your feature request related to a problem? Please describe.
When SafeQL is used with a database client including a row transformation function (eg. transforming snake case field names to camel case using Postgres.js postgres({ transform: postgres.camel })
), there is no way of configuring an equivalent transformation function in SafeQL.
This leads to the error Query has incorrect type annotation.
with the following code:
type Animal = {
id: number;
firstName: string;
};
const sql = postgres({ transform: postgres.camel });
async function query() {
// 💥 Error on next line: Query has incorrect type annotation
const animals = await sql<Animal[]>`
SELECT id, first_name FROM animals
`;
}
Describe the solution you'd like
It would be great to have ability to specify the transformation function of the type (maybe using the connections.transform
configuration option?).
Alternatively, if specification of an arbitrary function is complex, maybe having some common transformations would be enough, eg. fieldTransform: 'camelcase'
Describe alternatives you've considered
Use the type with the snake case properties as is and then transform the data later manually.
Additional context
--
Thanks for #51 @Newbie012 ! Looking great!
Owner Name | ts-safeql |
Repo Name | safeql |
Full Name | ts-safeql/safeql |
Language | TypeScript |
Created Date | 2022-09-08 |
Updated Date | 2023-03-28 |
Star Count | 801 |
Watcher Count | 5 |
Fork Count | 14 |
Issue Count | 7 |
Issue Title | Created Date | Updated Date |
---|