Add support for SQL::Statement-based DBDs
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / DBDFile.pm
1 package DBIx::Class::Storage::DBI::DBDFile;
2
3 use strict;
4 use base 'DBIx::Class::Storage::DBI';
5 use mro 'c3';
6 use DBIx::Class::Carp;
7 use namespace::clean;
8
9 __PACKAGE__->sql_maker_class('DBIx::Class::SQLMaker::SQLStatement');
10 __PACKAGE__->sql_quote_char('"');
11 __PACKAGE__->sql_limit_dialect('LimitXY');
12
13 # Unsupported options
14 sub _determine_supports_insert_returning { 0 };
15
16 # Statement caching currently buggy with either S:S or DBD::AnyData (and/or possibly others)
17 # Disable it here and look into fixing it later on
18 sub _init {
19    my $self = shift;
20    $self->next::method(@_);
21    $self->disable_sth_caching(1);
22 }
23
24 # No support for transactions; warn and continue
25 sub txn_begin {
26    carp_once <<'EOF' unless $ENV{DBIC_DBDFILE_TXN_NOWARN};
27 SQL::Statement-based drivers do not support transactions - proceeding at your own risk!
28
29 To turn off this warning, set the DBIC_DBDFILE_TXN_NOWARN environment variable.
30 EOF
31 }
32 sub txn_commit { 1; }
33 sub txn_rollback { shift->throw_exception('Transaction protection was ignored and unable to rollback - your data is likely inconsistent!'); }
34
35 # Nor is there any last_insert_id support (unless the driver supports it directly)
36 sub _dbh_last_insert_id { shift->throw_exception('SQL::Statement-based drivers do not support AUTOINCREMENT keys!  You will need to specify the PKs directly.'); }
37
38 1;
39
40 =head1 NAME
41
42 DBIx::Class::Storage::DBI::DBDFile - Base Class for SQL::Statement- / DBI::DBD::SqlEngine-based
43 DBD support in DBIx::Class
44
45 =head1 SYNOPSIS
46
47 This is the base class for DBDs that use L<SQL::Statement> and/or
48 L<DBI::DBD::SqlEngine|DBI::DBD::SqlEngine::Developers>, ie: based off of
49 L<DBD::File>.  This class is used for:
50
51 =over
52 =item L<DBD::AnyData>
53 =item L<DBD::TreeData>
54 =item L<DBD::CSV>
55 =item L<DBD::DBM>
56 =back
57
58 =head1 IMPLEMENTATION NOTES
59
60 =head2 Transactions
61
62 These drivers do not support transactions (and in fact, even the SQL syntax for
63 them).  Therefore, any attempts to use txn_* or svp_* methods will warn you once
64 and silently ignore the transaction protection.
65
66 =head2 SELECT ... FOR UPDATE/SHARE
67
68 This also is not supported, but it will silently ignore these.
69
70 =head1 AUTHOR
71
72 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
73
74 =head1 LICENSE
75
76 You may distribute this code under the same terms as Perl itself.
77
78 =cut