File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -263,14 +263,32 @@ protected virtual SqlResult CompileDeleteQuery(Query query)
263263 throw new InvalidOperationException ( "Invalid table expression" ) ;
264264 }
265265
266+ var joins = CompileJoins ( ctx ) ;
267+
266268 var where = CompileWheres ( ctx ) ;
267269
268270 if ( ! string . IsNullOrEmpty ( where ) )
269271 {
270272 where = " " + where ;
271273 }
272274
273- ctx . RawSql = $ "DELETE FROM { table } { where } ";
275+ if ( string . IsNullOrEmpty ( joins ) )
276+ {
277+ ctx . RawSql = $ "DELETE FROM { table } { where } ";
278+ }
279+ else
280+ {
281+ // check if we have alias
282+ if ( fromClause is FromClause && ! string . IsNullOrEmpty ( fromClause . Alias ) )
283+ {
284+ ctx . RawSql = $ "DELETE { Wrap ( fromClause . Alias ) } FROM { table } { joins } { where } ";
285+ }
286+ else
287+ {
288+ ctx . RawSql = $ "DELETE { table } FROM { table } { joins } { where } ";
289+ }
290+
291+ }
274292
275293 return ctx ;
276294 }
You can’t perform that action at this time.
0 commit comments