Add support for SQL::Statement-based DBDs
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / SQL / Statement.pm
CommitLineData
ac50f57b 1package DBIx::Class::Storage::DBI::SQL::Statement;
2
3use strict;
4use base 'DBIx::Class::Storage::DBI';
5use mro 'c3';
6use namespace::clean;
7
8__PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::SQLStatement');
9__PACKAGE__->sql_quote_char('"');
10__PACKAGE__->sql_limit_dialect('LimitXY_NoBinds');
11
12# Unsupported options
13sub _determine_supports_insert_returning { 0 };
14
15# Statement caching currently buggy with either S:S or DBD::AnyData (and/or possibly others)
16# Disable it here and look into fixing it later on
17sub _init {
18 my $self = shift;
19 $self->next::method(@_);
20 $self->disable_sth_caching(1);
21}
22
23# No support for transactions; sorry...
24sub txn_begin {
25 my $self = shift;
26
27 # Only certain internal calls are allowed through, and even then, we are merely
28 # ignoring the txn part
29 my $callers = join "\n", map { (caller($_))[3] } (1 .. 4);
30 return $self->_get_dbh
31 if ($callers =~ /
32 DBIx::Class::Storage::DBI::insert_bulk|
33 DBIx::Class::Relationship::CascadeActions::update
34 /x);
35
36 $self->throw_exception('SQL::Statement-based drivers do not support transactions!');
37}
38sub svp_begin { shift->throw_exception('SQL::Statement-based drivers do not support savepoints!'); }
39
40# Nor is there any last_insert_id support (unless the driver supports it directly)
41sub _dbh_last_insert_id { shift->throw_exception('SQL::Statement-based drivers do not support AUTOINCREMENT keys! You will need to specify the PKs directly.'); }
42
43# leftovers to support txn_begin exceptions
44sub txn_commit { 1; }
45
461;
47
48=head1 NAME
49
50DBIx::Class::Storage::DBI::SQL::Statement - Base Class for SQL::Statement- / DBI::DBD::SqlEngine-based
51DBD support in DBIx::Class
52
53=head1 SYNOPSIS
54
55This is the base class for DBDs that use L<SQL::Statement> and/or
56L<DBI::DBD::SqlEngine|DBI::DBD::SqlEngine::Developers>. This class is
57used for:
58
59=over
60=item L<DBD::Sys>
61=item L<DBD::AnyData>
62=item L<DBD::TreeData>
63=item L<DBD::SNMP>
64=item L<DBD::PO>
65=item L<DBD::CSV>
66=item L<DBD::DBM>
67=back
68
69=head1 IMPLEMENTATION NOTES
70
71=head2 Transactions
72
73These drivers do not support transactions (and in fact, even the SQL syntax for
74them). Therefore, any attempts to use txn_* or svp_* methods will throw an
75exception.
76
77In a future release, they may be replaced with emulated functionality. (Then
78again, it would probably be added into L<SQL::Statement> instead.)
79
80=head2 SELECT ... FOR UPDATE/SHARE
81
82This also is not supported, but it will silently ignore these.
83
84=head1 AUTHOR
85
86See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
87
88=head1 LICENSE
89
90You may distribute this code under the same terms as Perl itself.
91
92=cut