($self->_sqlcase('delete from ').$sql, @bind);
};
$self->{clauses_of}{insert} = [
- 'target', 'fields', 'values', 'returning'
+ 'target', 'fields', 'from', 'returning'
];
$self->{expand}{insert} = sub { shift->_expand_statement(@_) };
$self->{render}{insert} = sub { shift->_render_statement(insert => @_) };
my ($sql, @bind) = $self->render_aqt($from);
($self->_sqlcase('insert into ').$sql, @bind);
};
- $self->{render_clause}{'insert.values'} = sub {
+ $self->{render_clause}{'insert.from'} = sub {
return $_[0]->render_aqt($_[1]);
};
return $self;
@exp
}
} else {
- ($_ => $val)
+ ($_ => $self->expand_expr($val))
}
} sort keys %$args
} };
}
return $data if ref($data) eq 'HASH' and $data->{-row};
my ($f_aqt, $v_aqt) = $self->_expand_insert_values($data);
- return (values => { -values => $v_aqt }, ($f_aqt ? (fields => $f_aqt) : ()));
+ return (from => { -values => $v_aqt }, ($f_aqt ? (fields => $f_aqt) : ()));
}
1;
$new->{expand_clause}{'delete.using'} = sub {
+(using => $_[0]->_expand_from_list(undef, $_[1]));
};
+ $new->{expand_clause}{'insert.rowvalues'} = sub {
+ (from => $_[0]->expand_expr({ -values => $_[1] }));
+ };
+ $new->{expand_clause}{'insert.select'} = sub {
+ (from => $_[0]->expand_expr({ -select => $_[1] }));
+ };
return $new;
}
is_same_sql(
$sqlac->insert({
into => 'foo',
- values => { -select => { select => '*', from => 'bar' } }
+ select => { select => '*', from => 'bar' }
}),
q{INSERT INTO foo SELECT * FROM bar}
);
+($sql, @bind) = $sqlac->insert({
+ into => 'eh',
+ rowvalues => [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ]
+});
+
+is_same_sql_bind(
+ $sql, \@bind,
+ q{INSERT INTO eh VALUES (?, ?), (?, ?), (?, ?)},
+ [ 1..6 ],
+);
+
done_testing;