Mail-DMARC

 view release on metacpan or  search on metacpan

lib/Mail/DMARC/Report/Store/SQL/Grammars/SQLite.pm  view on Meta::CPAN

    my ( $self, $which ) = @_;
    if ( $which == 0 ) {
        return 'UPDATE report SET end=? WHERE id=?';
    } else {
        return 'INSERT INTO report_error (report_id, error) VALUES (?,?)';
    }
}

sub insert_rr_reason {
    return 'INSERT INTO report_record_reason (report_record_id, type, comment) VALUES (?,?,?)'
}

sub insert_rr_dkim {
    my ( $self, $fields ) = @_;
    my $fields_str = join ', ', @$fields;
    return <<"EO_DKIM"
INSERT INTO report_record_dkim
    (report_record_id, $fields_str)
VALUES (??)
EO_DKIM
    ;
}

sub insert_rr_spf {
    my ( $self, $fields ) = @_;
    my $fields_str = join ', ', @$fields;
    return "INSERT INTO report_record_spf (report_record_id, $fields_str) VALUES(??)";
}

sub insert_rr {
    return <<'EO_ROW_INSERT'
INSERT INTO report_record
   (report_id, source_ip, count, header_from_did, envelope_to_did, envelope_from_did,
    disposition, dkim, spf)
   VALUES (??)
EO_ROW_INSERT
    ;
}

sub insert_policy_published {
    return <<"EO_RPP"
INSERT INTO report_policy_published
  (report_id, adkim, aspf, p, sp, pct, rua)
VALUES (??)
EO_RPP
    ;
}

sub select_from {
    my ($self, $columns, $table) = @_;
    my $colStr = join( ', ', @$columns );
    return "SELECT $colStr FROM $table WHERE 1=1";
}

sub insert_into {
    my ($self, $table, $cols) = @_;
    my $columns = join ', ', @$cols;
    return "INSERT INTO $table ($columns) VALUES (??)";
}

sub update {
    my ($self, $table, $cols) = @_;
    my $columns = join( ' = ?, ') . ' = ?';
    return "UPDATE $table SET $columns WHERE 1=1";
}

sub replace_into {
    my ($self, $table, $cols) = @_;
    my $columns = join ', ', @$cols;
    return "REPLACE INTO $table ($columns) VALUES (??)";
}

sub delete_from {
    my ($self, $table) = @_;
    return "DELETE FROM $table WHERE 1=1";
}

1;

__END__

=pod

=head1 NAME

Mail::DMARC::Report::Store::SQL::Grammars::SQLite - Grammar for working with sqlite databases.

=head1 VERSION

version 1.20260306

=head1 SYPNOSIS

Allow DMARC to be able to speak to SQLite databases.

=head1 DESCRIPTION

Uses ANSI SQL syntax, keeping the SQL as portable as possible.

DB engine specific features are to be avoided.

=head1 AUTHORS

=over 4

=item *

Matt Simerson <msimerson@cpan.org>

=item *

Davide Migliavacca <shari@cpan.org>

=item *

Marc Bradshaw <marc@marcbradshaw.net>

=back

=head1 COPYRIGHT AND LICENSE



( run in 1.061 second using v1.01-cache-2.11-cpan-39bf76dae61 )