1 package DBIx::Class::Storage::DBI::SQLAnywhere;
5 use base qw/DBIx::Class::Storage::DBI/;
9 __PACKAGE__->mk_group_accessors(simple => qw/
15 DBIx::Class::Storage::DBI::SQLAnywhere - Driver for Sybase SQL Anywhere
19 This class implements autoincrements for Sybase SQL Anywhere and selects the
20 RowNumberOver limit implementation.
22 You need the C<DBD::SQLAnywhere> driver that comes with the SQL Anywhere
23 distribution, B<NOT> the one on CPAN. It is usually under a path such as:
25 /opt/sqlanywhere11/sdk/perl
27 Recommended L<DBIx::Class::Storage::DBI/connect_info> settings:
29 on_connect_call => 'datetime_setup'
35 sub last_insert_id { shift->_identity }
39 my ($source, $to_insert) = @_;
41 my $supplied_col_info = $self->_resolve_column_info($source, [keys %$to_insert]);
43 my $is_identity_insert = (List::Util::first { $_->{is_auto_increment} } (values %$supplied_col_info) )
47 my $identity_col = List::Util::first {
48 $source->column_info($_)->{is_auto_increment}
51 if ((not $is_identity_insert) && $identity_col) {
52 my $dbh = $self->_get_dbh;
53 my $table_name = $source->from;
54 $table_name = $$table_name if ref $table_name;
56 my ($identity) = $dbh->selectrow_array("SELECT GET_IDENTITY('$table_name')");
58 $to_insert->{$identity_col} = $identity;
60 $self->_identity($identity);
63 return $self->next::method(@_);
66 # this sub stolen from DB2
69 my ( $self, $opts ) = @_;
72 $self->{_sql_maker_opts} = { %$opts };
75 return { limit_dialect => 'RowNumberOver', %{$self->{_sql_maker_opts}||{}} };
78 # this sub stolen from MSSQL
80 sub build_datetime_parser {
82 my $type = "DateTime::Format::Strptime";
84 $self->throw_exception("Couldn't load ${type}: $@") if $@;
85 return $type->new( pattern => '%Y-%m-%d %H:%M:%S.%6N' );
88 =head2 connect_call_datetime_setup
92 on_connect_call => 'datetime_setup'
94 In L<DBIx::Class::Storage::DBI/connect_info> to set the date and timestamp
95 formats (as temporary options for the session) for use with
96 L<DBIx::Class::InflateColumn::DateTime>.
98 The C<TIMESTAMP> data type supports up to 6 digits after the decimal point for
99 second precision. The full precision is used.
101 The C<DATE> data type supposedly stores hours and minutes too, according to the
102 documentation, but I could not get that to work. It seems to only store the
105 You will need the L<DateTime::Format::Strptime> module for inflation to work.
109 sub connect_call_datetime_setup {
113 "set temporary option timestamp_format = 'yyyy-mm-dd hh:mm:ss.ssssss'"
116 "set temporary option date_format = 'yyyy-mm-dd hh:mm:ss.ssssss'"
124 See L<DBIx::Class/AUTHOR> and L<DBIx::Class/CONTRIBUTORS>.
128 You may distribute this code under the same terms as Perl itself.