@@ -23,6 +23,10 @@ yy.Insert.prototype.toString = function () {
2323 s += ' VALUES ' + values . join ( ',' ) ;
2424 }
2525 if ( this . select ) s += ' ' + this . select . toString ( ) ;
26+ if ( this . setcolumns ) {
27+ s += ' SET ' ;
28+ s += this . setcolumns . map ( col => col . toString ( ) ) . join ( ', ' ) ;
29+ }
2630 if ( this . output ) {
2731 s += ' OUTPUT ' ;
2832 s += this . output . columns . map ( col => col . toString ( ) ) . join ( ', ' ) ;
@@ -331,6 +335,31 @@ yy.Insert.prototype.compile = function (databaseid) {
331335 } else if ( this . default ) {
332336 var insertfns = "db.tables['" + tableid + "'].data.push({" + table . defaultfns + '});return 1;' ;
333337 var insertfn = new Function ( 'db,params,alasql' , insertfns ) ;
338+ } else if ( this . setcolumns ) {
339+ // INSERT INTO table SET column = value - convert to VALUES equivalent
340+ // Build column list and value expression list from SET columns
341+ var columns = [ ] ;
342+ var valueExprs = [ ] ;
343+ this . setcolumns . forEach ( function ( setcol ) {
344+ columns . push ( setcol . column ) ;
345+ valueExprs . push ( setcol . expression ) ;
346+ } ) ;
347+
348+ // Temporarily transform to use VALUES path
349+ var originalColumns = this . columns ;
350+ var originalValues = this . values ;
351+ this . columns = columns ;
352+ this . values = [ valueExprs ] ;
353+
354+ try {
355+ // Reuse VALUES compilation logic by recursively calling compile
356+ var compiledFn = yy . Insert . prototype . compile . call ( this , databaseid ) ;
357+ return compiledFn ;
358+ } finally {
359+ // Always restore original state
360+ this . columns = originalColumns ;
361+ this . values = originalValues ;
362+ }
334363 } else {
335364 throw new Error ( 'Wrong INSERT parameters' ) ;
336365 }
0 commit comments