@@ -128,6 +128,14 @@ module SqlGen =
128128 | [ first; second ] -> first, second
129129 | _ -> failwith ( " SqlGen: " + string fn + " takes exactly two arguments" )
130130
131+ let private renderSource ( b : Builder ) ( s : Source ) =
132+ let append ( t : string ) = write b t
133+
134+ if s.Alias = s.Table then
135+ append s.Table
136+ else
137+ append $" {s.Table} AS {s.Alias}"
138+
131139 /// ` .Date ` . SQLite and MySQL have DATE(); PostgreSQL's DATE() is not the
132140 /// same thing, so it uses the truncation SQLProvider uses too.
133141
@@ -139,7 +147,7 @@ module SqlGen =
139147 match e with
140148 | ColumnRef( table, column) ->
141149 if b.Qualify then
142- append ( $" {table}.{column}" )
150+ append $" {table}.{column}"
143151 else
144152 append column
145153
@@ -500,11 +508,11 @@ module SqlGen =
500508 | Sqlite ->
501509 // STRFTIME returns text, so cast back to a number to keep
502510 // comparisons behaving like the other engines.
503- append ( $" CAST(STRFTIME('{strftime}', " )
511+ append $" CAST(STRFTIME('{strftime}', "
504512 renderExpr b arg
505513 append " ) AS INTEGER)"
506514 | Postgres ->
507- append ( $" EXTRACT({name} FROM " )
515+ append $" EXTRACT({name} FROM "
508516 renderExpr b arg
509517 append " )"
510518 | MySql
@@ -587,17 +595,9 @@ module SqlGen =
587595
588596 append " DATETIME("
589597 renderExpr b inner
590- append ( $" , '{signed} {unitName}s')" )
598+ append $" , '{signed} {unitName}s')"
591599
592- and private renderSource ( b : Builder ) ( s : Source ) =
593- let append ( t : string ) = write b t
594-
595- if s.Alias = s.Table then
596- append s.Table
597- else
598- append ( $" {s.Table} AS {s.Alias}" )
599-
600- /// Renders a query into an existing builder, so a subquery shares the outer
600+ /// Renders a query into an existing builder, so a subquery shares the outer
601601 /// statement's parameter list and stays numbered in the order the SQL
602602 /// mentions it.
603603 /// One SELECT through its HAVING -- everything that belongs to a single
@@ -763,7 +763,7 @@ module SqlGen =
763763
764764 let renderInsert ( vendor : Vendor ) ( i : Insert ) : string * SqlParam [] =
765765 if i.Assignments.Length = 0 then
766- failwith " SqlGen: the insert sets no columns"
766+ failwith $ " SqlGen: the insert sets no columns, calling renderInsert with vendor: {vendor} "
767767
768768 // Columns are bare here, not qualified: an INSERT names exactly one
769769 // table and every engine rejects `INSERT INTO t (t.c) ..`.
@@ -798,10 +798,10 @@ module SqlGen =
798798 /// would stop the statement being atomic.
799799 let renderInsertMany ( vendor : Vendor ) ( i : InsertMany ) : string * SqlParam [] =
800800 if i.Columns.Length = 0 then
801- failwith " SqlGen: the insert sets no columns"
801+ failwith $ " SqlGen: the insert sets no columns, calling renderInsertMany with vendor: {vendor} "
802802
803803 if i.Rows.Length = 0 then
804- failwith " SqlGen: the insert has no rows"
804+ failwith $ " SqlGen: the insert has no rows, calling renderInsertMany with vendor: {vendor} "
805805
806806 let b = newBuilder vendor false
807807 write b ( $" INSERT INTO {i.Table} (" )
@@ -857,10 +857,10 @@ module SqlGen =
857857
858858 let renderUpdate ( vendor : Vendor ) ( u : Update ) : string * SqlParam [] =
859859 if u.Assignments.Length = 0 then
860- failwith " SqlGen: the update sets no columns"
860+ failwith $ " SqlGen: the update sets no columns, calling renderUpdate with vendor: {vendor} "
861861
862862 if u.Where.IsNone && not u.Unconditional then
863- failwith " SqlGen: the update has no WHERE and would rewrite every row -- say Update.all if that is meant"
863+ failwith $ " SqlGen: the update has no WHERE and would rewrite every row -- say Update.all if that is meant, calling renderUpdate with vendor: {vendor} "
864864
865865 let b = newBuilder vendor false
866866 write b ( $" UPDATE {u.Table} SET " )
@@ -876,7 +876,7 @@ module SqlGen =
876876
877877 let renderDelete ( vendor : Vendor ) ( d : Delete ) : string * SqlParam [] =
878878 if d.Where.IsNone && not d.Unconditional then
879- failwith " SqlGen: the delete has no WHERE and would empty the table -- say Delete.all if that is meant"
879+ failwith $ " SqlGen: the delete has no WHERE and would empty the table -- say Delete.all if that is meant, calling renderDelete with vendor: {vendor} "
880880
881881 let b = newBuilder vendor false
882882 write b ( " DELETE FROM " + d.Table)
0 commit comments