1 package DBIx::Class::Schema::Loader::DBI::ADO::MS_Jet;
6 DBIx::Class::Schema::Loader::DBI::ADO
7 DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS
10 use Carp::Clan qw/^DBIx::Class/;
14 our $VERSION = '0.07010';
18 DBIx::Class::Schema::Loader::DBI::ADO::MS_Jet - ADO wrapper for
19 L<DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS>
23 Proxy for L<DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS> when using
26 See L<DBIx::Class::Schema::Loader::Base> for usage information.
33 $self->schema->storage->dbh->get_info(2);
39 return $self->__ado_connection if $self->__ado_connection;
41 my ($dsn, $user, $pass) = @{ $self->schema->storage->_dbi_connect_info };
45 if (ref $dsn eq 'CODE') {
46 ($dsn, $user, $pass) = $self->_try_infer_connect_info_from_coderef($dsn);
49 my $dbh = $self->schema->storage->dbh;
51 $user = $dbh->{Username};
57 my $conn = Win32::OLE->new('ADODB.Connection');
59 $dsn =~ s/^dbi:[^:]+://i;
61 local $Win32::OLE::Warn = 0;
64 for my $s (split /;/, $dsn) {
65 my ($k, $v) = split /=/, $s, 2;
66 if (defined $conn->{$k}) {
73 $dsn = join ';', @dsn;
75 $user = '' unless defined $user;
77 if ((not $have_pass) && exists $self->_passwords->{$dsn}{$user}) {
78 $pass = $self->_passwords->{$dsn}{$user};
81 $pass = '' unless defined $pass;
84 $conn->Open($dsn, $user, $pass);
88 if (exists $ENV{DBI_PASS}) {
89 $pass = $ENV{DBI_PASS};
91 $conn->Open($dsn, $user, $pass);
92 $self->_passwords->{$dsn}{$user} = $pass;
95 print "Enter database password for $user ($dsn): ";
96 chomp($pass = <STDIN>);
97 $conn->Open($dsn, $user, $pass);
98 $self->_passwords->{$dsn}{$user} = $pass;
102 print "Enter database password for $user ($dsn): ";
103 chomp($pass = <STDIN>);
104 $conn->Open($dsn, $user, $pass);
105 $self->_passwords->{$dsn}{$user} = $pass;
113 $self->__ado_connection($conn);
118 sub _columns_info_for {
122 my $result = $self->next::method(@_);
124 while (my ($col, $info) = each %$result) {
125 my $data_type = $info->{data_type};
127 my $col_obj = $self->_adox_column($table, $col);
129 if ($data_type eq 'long') {
130 $info->{data_type} = 'integer';
131 delete $info->{size};
133 my $props = $col_obj->Properties;
134 for my $prop_idx (0..$props->Count-1) {
135 my $prop = $props->Item($prop_idx);
136 if ($prop->Name eq 'Autoincrement' && $prop->Value == 1) {
137 $info->{is_auto_increment} = 1;
142 elsif ($data_type eq 'short') {
143 $info->{data_type} = 'smallint';
144 delete $info->{size};
146 elsif ($data_type eq 'single') {
147 $info->{data_type} = 'real';
148 delete $info->{size};
150 elsif ($data_type eq 'money') {
151 if (ref $info->{size} eq 'ARRAY') {
152 if ($info->{size}[0] == 19 && $info->{size}[1] == 255) {
153 delete $info->{size};
156 # it's really a decimal
157 $info->{data_type} = 'decimal';
159 if ($info->{size}[0] == 18 && $info->{size}[1] == 0) {
161 delete $info->{size};
163 delete $info->{original};
167 elsif ($data_type eq 'varchar') {
168 $info->{data_type} = 'char' if $col_obj->Type == 130;
169 $info->{size} = $col_obj->DefinedSize;
171 elsif ($data_type eq 'bigbinary') {
172 $info->{data_type} = 'varbinary';
174 my $props = $col_obj->Properties;
175 for my $prop_idx (0..$props->Count-1) {
176 my $prop = $props->Item($prop_idx);
177 if ($prop->Name eq 'Fixed Length' && $prop->Value == 1) {
178 $info->{data_type} = 'binary';
183 $info->{size} = $col_obj->DefinedSize;
185 elsif ($data_type eq 'longtext') {
186 $info->{data_type} = 'text';
187 $info->{original}{data_type} = 'longchar';
188 delete $info->{size};
197 L<DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS>,
198 L<DBIx::Class::Schema::Loader::DBI::ADO>,
199 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
200 L<DBIx::Class::Schema::Loader::DBI>
204 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
208 This library is free software; you can redistribute it and/or modify it under
209 the same terms as Perl itself.
214 # vim:et sts=4 sw=4 tw=0: