1 package DBIx::Class::Storage::DBI::ADO::MS_Jet;
7 DBIx::Class::Storage::DBI::ADO
8 DBIx::Class::Storage::DBI::ACCESS
12 use DBIx::Class::Storage::DBI::ADO::CursorUtils '_normalize_guids';
13 use DBIx::Class::ResultSource::FromSpec::Util 'fromspec_columns_info';
16 __PACKAGE__->cursor_class('DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor');
20 DBIx::Class::Storage::DBI::ADO::MS_Jet - Support for MS Access over ADO
24 This driver is a subclass of L<DBIx::Class::Storage::DBI::ADO> and
25 L<DBIx::Class::Storage::DBI::ACCESS> for connecting to MS Access via
28 See the documentation for L<DBIx::Class::Storage::DBI::ACCESS> for
29 information on the MS Access driver for L<DBIx::Class>.
31 This driver implements workarounds for C<TEXT/IMAGE/MEMO> columns, sets the
32 L<cursor_class|DBIx::Class::Storage::DBI/cursor_class> to
33 L<DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor> to normalize returned
34 C<GUID> values and provides L<DBIx::Class::InflateColumn::DateTime> support
35 for C<DATETIME> columns.
39 # older Access versions:
40 dbi:ADO:Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\rkitover\Documents\access_sample.accdb
42 # newer Access versions:
43 dbi:ADO:Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\rkitover\Documents\access_sample.accdb;Persist Security Info=False'
45 =head1 TEXT/IMAGE/MEMO COLUMNS
47 The ADO driver does not suffer from the
48 L<problems|DBIx::Class::Storage::DBI::ODBC::ACCESS/"TEXT/IMAGE/MEMO COLUMNS">
49 the L<ODBC|DBIx::Class::Storage::DBI::ODBC::ACCESS> driver has with these types
50 of columns. You can use them safely.
52 When you execute a C<CREATE TABLE> statement over this driver with a C<TEXT>
53 column, it will be converted to C<MEMO>, while in the
54 L<ODBC|DBIx::Class::Storage::DBI::ODBC::ACCESS> driver it is converted to
57 However, the caveat about L<LongReadLen|DBI/LongReadLen> having to be twice the
58 max size of your largest C<MEMO/TEXT> column C<+1> still applies. L<DBD::ADO>
59 sets L<LongReadLen|DBI/LongReadLen> to a large value by default, so it should be
60 safe to just leave it unset. If you do pass a L<LongReadLen|DBI/LongReadLen> in
61 your L<connect_info|DBIx::Class::Storage::DBI/connect_info>, it will be
62 multiplied by two and C<1> added, just as for the
63 L<ODBC|DBIx::Class::Storage::DBI::ODBC::ACCESS> driver.
67 # set LongReadLen = LongReadLen * 2 + 1 (see docs on MEMO)
68 sub _run_connection_actions {
71 my $long_read_len = $self->_dbh->{LongReadLen};
73 # This is the DBD::ADO default.
74 if ($long_read_len != 2147483647) {
75 $self->_dbh->{LongReadLen} = $long_read_len * 2 + 1;
78 return $self->next::method(@_);
81 # AutoCommit does not get reset properly after transactions for some reason
82 # (probably because of my nested transaction hacks in ACCESS.pm) fix it up
85 sub _exec_txn_commit {
87 $self->next::method(@_);
88 $self->_dbh->{AutoCommit} = $self->_dbh_autocommit
89 if $self->{transaction_depth} == 1;
92 sub _exec_txn_rollback {
94 $self->next::method(@_);
95 $self->_dbh->{AutoCommit} = $self->_dbh_autocommit
96 if $self->{transaction_depth} == 1;
99 # Fix up GUIDs for ->find, for cursors see the cursor_class above.
103 my ($ident, $select) = @_;
105 my @row = $self->next::method(@_);
108 $self->cursor_class->isa('DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor');
110 my $col_infos = fromspec_columns_info($ident);
112 _normalize_guids($select, $col_infos, \@row, $self);
117 sub datetime_parser_type {
118 'DBIx::Class::Storage::DBI::ADO::MS_Jet::DateTime::Format'
121 package # hide from PAUSE
122 DBIx::Class::Storage::DBI::ADO::MS_Jet::DateTime::Format;
124 my $datetime_format = '%m/%d/%Y %I:%M:%S %p';
129 require DateTime::Format::Strptime;
130 $datetime_parser ||= DateTime::Format::Strptime->new(
131 pattern => $datetime_format,
134 return $datetime_parser->parse_datetime(shift);
137 sub format_datetime {
139 require DateTime::Format::Strptime;
140 $datetime_parser ||= DateTime::Format::Strptime->new(
141 pattern => $datetime_format,
144 return $datetime_parser->format_datetime(shift);
147 =head1 FURTHER QUESTIONS?
149 Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
151 =head1 COPYRIGHT AND LICENSE
153 This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
154 by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
155 redistribute it and/or modify it under the same terms as the
156 L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.