use Scalar::Util ();
use Data::Query::Constants qw(
DQ_IDENTIFIER DQ_OPERATOR DQ_VALUE DQ_LITERAL DQ_JOIN DQ_SELECT DQ_ORDER
- DQ_WHERE
+ DQ_WHERE DQ_DELETE
);
use Data::Query::ExprHelpers qw(perl_scalar_value);
# SELECT
#======================================================================
-
-sub select {
- my $self = shift;
- my $table = shift;
- my $fields = shift || '*';
- my $where = shift;
- my $order = shift;
+sub _source_to_dq {
+ my ($self, $table, $where) = @_;
my $source_dq = $self->_table_to_dq($table);
};
}
+ $source_dq;
+}
+
+sub select {
+ my $self = shift;
+ my $table = shift;
+ my $fields = shift || '*';
+ my $where = shift;
+ my $order = shift;
+
+ my $source_dq = $self->_source_to_dq($table, $where);
+
my $final_dq = {
type => DQ_SELECT,
select => [
sub delete {
my $self = shift;
- my $table = $self->_table(shift);
- my $where = shift;
-
-
- my($where_sql, @bind) = $self->where($where);
- my $sql = $self->_sqlcase('delete from') . " $table" . $where_sql;
+ $self->_render_dq($self->_delete_to_dq(@_));
+}
- return wantarray ? ($sql, @bind) : $sql;
+sub _delete_to_dq {
+ my $self = shift;
+ +{
+ type => DQ_DELETE,
+ from => $self->_source_to_dq(@_)
+ }
}