@@ -92,7 +92,7 @@ func (p *InsertInto) Execute(ctx *sql.Context) (int, error) {
9292 p .Columns [i ] = f .Name
9393 }
9494 } else {
95- err = p .validateColumns (ctx , dstSchema )
95+ err = p .validateColumns (dstSchema )
9696 if err != nil {
9797 return 0 , err
9898 }
@@ -139,7 +139,7 @@ func (p *InsertInto) Execute(ctx *sql.Context) (int, error) {
139139 return i , err
140140 }
141141
142- err = p .validateNullability (ctx , dstSchema , row )
142+ err = p .validateNullability (dstSchema , row )
143143 if err != nil {
144144 _ = iter .Close ()
145145 return i , err
@@ -227,13 +227,15 @@ func (p *InsertInto) validateValueCount(ctx *sql.Context) error {
227227 return p .assertSchemasMatch (node .Schema ())
228228 case * Project :
229229 return p .assertSchemasMatch (node .Schema ())
230+ case * InnerJoin :
231+ return p .assertSchemasMatch (node .Schema ())
230232 default :
231233 return ErrInsertIntoUnsupportedValues .New (node )
232234 }
233235 return nil
234236}
235237
236- func (p * InsertInto ) validateColumns (ctx * sql. Context , dstSchema sql.Schema ) error {
238+ func (p * InsertInto ) validateColumns (dstSchema sql.Schema ) error {
237239 dstColNames := make (map [string ]struct {})
238240 for _ , dstCol := range dstSchema {
239241 dstColNames [dstCol .Name ] = struct {}{}
@@ -252,7 +254,7 @@ func (p *InsertInto) validateColumns(ctx *sql.Context, dstSchema sql.Schema) err
252254 return nil
253255}
254256
255- func (p * InsertInto ) validateNullability (ctx * sql. Context , dstSchema sql.Schema , row sql.Row ) error {
257+ func (p * InsertInto ) validateNullability (dstSchema sql.Schema , row sql.Row ) error {
256258 for i , col := range dstSchema {
257259 if ! col .Nullable && row [i ] == nil {
258260 return ErrInsertIntoNonNullableProvidedNull .New (col .Name )
@@ -262,7 +264,7 @@ func (p *InsertInto) validateNullability(ctx *sql.Context, dstSchema sql.Schema,
262264}
263265
264266func (p * InsertInto ) assertSchemasMatch (schema sql.Schema ) error {
265- if len (p .Schema ()) != len (p . Schema () ) {
267+ if len (p .Columns ) != len (schema ) {
266268 return ErrInsertIntoMismatchValueCount .New ()
267269 }
268270 return nil
0 commit comments