File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -477,7 +477,11 @@ export class Driver {
477477 return factory . createObjectLiteralExpression (
478478 columns . map ( ( col , i ) =>
479479 factory . createPropertyAssignment (
480- factory . createIdentifier ( singularize ( colName ( i , col ) ) ) ,
480+ factory . createIdentifier (
481+ embeds . has ( col . name )
482+ ? singularize ( colName ( i , col ) )
483+ : colName ( i , col ) ,
484+ ) ,
481485 ! embeds . has ( col . name )
482486 ? this . buildColumnAccessExpression ( col , "row" , i )
483487 : factory . createObjectLiteralExpression (
Original file line number Diff line number Diff line change @@ -6,6 +6,9 @@ await prepare(sql`
66 SELECT e.*, sqlc.embed(a) FROM emails e
77 join authors a on a.name = 'John Doe'
88 limit 1;
9+
10+ -- name: AuthorExists :one
11+ SELECT 1::int as noPrimitiveReturn, exists(select 1 from authors where name = 'John Doe') as exists;
912` ) ;
1013
1114describe ( "sqlc.embed" , ( ) => {
@@ -21,4 +24,10 @@ describe("sqlc.embed", () => {
2124 born : new Date ( "1990-02-09" ) ,
2225 } ) ;
2326 } ) ;
27+
28+ it ( "only singularizes fields for embeds" , async ( ) => {
29+ const result = await gen ( ) . authorExists ( db ) ;
30+ console . log ( result ) ;
31+ expect ( result . exists ) . toBe ( true ) ;
32+ } ) ;
2433} ) ;
You can’t perform that action at this time.
0 commit comments