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
13 our $VERSION = '0.07024';
17 DBIx::Class::Schema::Loader::DBI::ADO::MS_Jet - ADO wrapper for
18 L<DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS>
22 Proxy for L<DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS> when using
25 See L<DBIx::Class::Schema::Loader::Base> for usage information.
32 $self->schema->storage->dbh->get_info(2);
38 return $self->__ado_connection if $self->__ado_connection;
40 my ($dsn, $user, $pass) = @{ $self->schema->storage->_dbi_connect_info };
44 if (ref $dsn eq 'CODE') {
45 ($dsn, $user, $pass) = $self->_try_infer_connect_info_from_coderef($dsn);
48 my $dbh = $self->schema->storage->dbh;
50 $user = $dbh->{Username};
56 my $conn = Win32::OLE->new('ADODB.Connection');
58 $dsn =~ s/^dbi:[^:]+://i;
60 local $Win32::OLE::Warn = 0;
63 for my $s (split /;/, $dsn) {
64 my ($k, $v) = split /=/, $s, 2;
65 if (defined $conn->{$k}) {
72 $dsn = join ';', @dsn;
74 $user = '' unless defined $user;
76 if ((not $have_pass) && exists $self->_passwords->{$dsn}{$user}) {
77 $pass = $self->_passwords->{$dsn}{$user};
80 $pass = '' unless defined $pass;
83 $conn->Open($dsn, $user, $pass);
87 if (exists $ENV{DBI_PASS}) {
88 $pass = $ENV{DBI_PASS};
90 $conn->Open($dsn, $user, $pass);
91 $self->_passwords->{$dsn}{$user} = $pass;
94 print "Enter database password for $user ($dsn): ";
95 chomp($pass = <STDIN>);
96 $conn->Open($dsn, $user, $pass);
97 $self->_passwords->{$dsn}{$user} = $pass;
101 print "Enter database password for $user ($dsn): ";
102 chomp($pass = <STDIN>);
103 $conn->Open($dsn, $user, $pass);
104 $self->_passwords->{$dsn}{$user} = $pass;
112 $self->__ado_connection($conn);
117 sub _columns_info_for {
121 my $result = $self->next::method(@_);
123 while (my ($col, $info) = each %$result) {
124 my $data_type = $info->{data_type};
126 my $col_obj = $self->_adox_column($table, $col);
128 if ($data_type eq 'long') {
129 $info->{data_type} = 'integer';
130 delete $info->{size};
132 my $props = $col_obj->Properties;
133 for my $prop_idx (0..$props->Count-1) {
134 my $prop = $props->Item($prop_idx);
135 if ($prop->Name eq 'Autoincrement' && $prop->Value == 1) {
136 $info->{is_auto_increment} = 1;
141 elsif ($data_type eq 'short') {
142 $info->{data_type} = 'smallint';
143 delete $info->{size};
145 elsif ($data_type eq 'single') {
146 $info->{data_type} = 'real';
147 delete $info->{size};
149 elsif ($data_type eq 'money') {
150 if (ref $info->{size} eq 'ARRAY') {
151 if ($info->{size}[0] == 19 && $info->{size}[1] == 255) {
152 delete $info->{size};
155 # it's really a decimal
156 $info->{data_type} = 'decimal';
158 if ($info->{size}[0] == 18 && $info->{size}[1] == 0) {
160 delete $info->{size};
162 delete $info->{original};
166 elsif ($data_type eq 'varchar') {
167 $info->{data_type} = 'char' if $col_obj->Type == 130;
168 $info->{size} = $col_obj->DefinedSize;
170 elsif ($data_type eq 'bigbinary') {
171 $info->{data_type} = 'varbinary';
173 my $props = $col_obj->Properties;
174 for my $prop_idx (0..$props->Count-1) {
175 my $prop = $props->Item($prop_idx);
176 if ($prop->Name eq 'Fixed Length' && $prop->Value == 1) {
177 $info->{data_type} = 'binary';
182 $info->{size} = $col_obj->DefinedSize;
184 elsif ($data_type eq 'longtext') {
185 $info->{data_type} = 'text';
186 $info->{original}{data_type} = 'longchar';
187 delete $info->{size};
196 L<DBIx::Class::Schema::Loader::DBI::ODBC::ACCESS>,
197 L<DBIx::Class::Schema::Loader::DBI::ADO>,
198 L<DBIx::Class::Schema::Loader>, L<DBIx::Class::Schema::Loader::Base>,
199 L<DBIx::Class::Schema::Loader::DBI>
203 See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
207 This library is free software; you can redistribute it and/or modify it under
208 the same terms as Perl itself.
213 # vim:et sts=4 sw=4 tw=0: