1 package DBIx::Class::Storage::DBI::ADO::MS_Jet;
6 DBIx::Class::Storage::DBI::ADO
7 DBIx::Class::Storage::DBI::ACCESS
10 use DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor ();
12 __PACKAGE__->cursor_class('DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor');
16 DBIx::Class::Storage::DBI::ADO::MS_Jet - Support for MS Access over ADO
20 This driver is a subclass of L<DBIx::Class::Storage::DBI::ADO> and
21 L<DBIx::Class::Storage::DBI::ACCESS> for connecting to MS Access via
24 See the documentation for L<DBIx::Class::Storage::DBI::ACCESS> for
25 information on the MS Access driver for L<DBIx::Class>.
27 This driver implements workarounds for C<TEXT/IMAGE/MEMO> columns, sets the
28 L<cursor_class|DBIx::Class::Storage::DBI/cursor_class> to
29 L<DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor> to normalize returned
30 C<GUID> values and provides L<DBIx::Class::InflateColumn::DateTime> support
31 for C<DATETIME> columns.
35 # older Access versions:
36 dbi:ADO:Microsoft.Jet.OLEDB.4.0;Data Source=C:\Users\rkitover\Documents\access_sample.accdb
38 # newer Access versions:
39 dbi:ADO:Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\rkitover\Documents\access_sample.accdb;Persist Security Info=False'
41 =head1 TEXT/IMAGE/MEMO COLUMNS
43 The ADO driver does not suffer from the
44 L<problems|DBIx::Class::Storage::DBI::ODBC::ACCESS/"TEXT/IMAGE/MEMO COLUMNS">
45 the L<ODBC|DBIx::Class::Storage::DBI::ODBC::ACCESS> driver has with these types
46 of columns. You can use them safely.
48 When you execute a C<CREATE TABLE> statement over this driver with a C<TEXT>
49 column, it will be converted to C<MEMO>, while in the
50 L<ODBC|DBIx::Class::Storage::DBI::ODBC::ACCESS> driver it is converted to
53 However, the caveat about L<LongReadLen|DBI/LongReadLen> having to be twice the
54 max size of your largest C<MEMO/TEXT> column C<+1> still applies. L<DBD::ADO>
55 sets L<LongReadLen|DBI/LongReadLen> to a large value by default, so it should be
56 safe to just leave it unset. If you do pass a L<LongReadLen|DBI/LongReadLen> in
57 your L<connect_info|DBIx::Class::Storage::DBI/connect_info>, it will be
58 multiplied by two and C<1> added, just as for the
59 L<ODBC|DBIx::Class::Storage::DBI::ODBC::ACCESS> driver.
63 # set LongReadLen = LongReadLen * 2 + 1 (see docs on MEMO)
64 sub _run_connection_actions {
67 my $long_read_len = $self->_dbh->{LongReadLen};
69 # This is the DBD::ADO default.
70 if ($long_read_len != 2147483647) {
71 $self->_dbh->{LongReadLen} = $long_read_len * 2 + 1;
74 return $self->next::method(@_);
77 # AutoCommit does not get reset properly after transactions for some reason
78 # (probably because of my nested transaction hacks in ACCESS.pm) fix it up
83 $self->next::method(@_);
84 $self->_dbh->{AutoCommit} = $self->_dbh_autocommit
85 if $self->{transaction_depth} == 1;
90 $self->next::method(@_);
91 $self->_dbh->{AutoCommit} = $self->_dbh_autocommit
92 if $self->{transaction_depth} == 1;
95 # Fix up GUIDs for ->find, for cursors see the cursor_class above.
99 my ($ident, $select) = @_;
101 my @row = $self->next::method(@_);
104 $self->cursor_class->isa('DBIx::Class::Storage::DBI::ADO::MS_Jet::Cursor');
106 my $col_info = $self->_resolve_column_info($ident);
108 for my $select_idx (0..$#$select) {
109 my $selected = $select->[$select_idx];
111 next if ref $selected;
113 my $data_type = $col_info->{$selected}{data_type};
115 if ($self->_is_guid_type($data_type)) {
116 my $returned = $row[$select_idx];
118 $row[$select_idx] = substr($returned, 1, 36)
119 if substr($returned, 0, 1) eq '{';
126 sub datetime_parser_type {
127 'DBIx::Class::Storage::DBI::ADO::MS_Jet::DateTime::Format'
130 package # hide from PAUSE
131 DBIx::Class::Storage::DBI::ADO::MS_Jet::DateTime::Format;
133 my $datetime_format = '%m/%d/%Y %I:%M:%S %p';
138 require DateTime::Format::Strptime;
139 $datetime_parser ||= DateTime::Format::Strptime->new(
140 pattern => $datetime_format,
143 return $datetime_parser->parse_datetime(shift);
146 sub format_datetime {
148 require DateTime::Format::Strptime;
149 $datetime_parser ||= DateTime::Format::Strptime->new(
150 pattern => $datetime_format,
153 return $datetime_parser->format_datetime(shift);
160 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
164 You may distribute this code under the same terms as Perl itself.