1 { # Based on the change to Class::DBI in OpenILS::Application::Storage. This will
2 # allow us to use TSearch2 via a simple cdbi "search" interface.
3 #-------------------------------------------------------------------------------
10 if (ref($args[-1]) eq 'HASH') {
11 $args[-1]->{_placeholder} = "to_tsquery('default',?)";
13 push @args, {_placeholder => "to_tsquery('default',?)"};
15 $self->_do_search("@@" => @args);
19 { # Every driver needs to provide a 'compile()' method to OpenILS::Application::Storage::FTS.
20 # If that driver wants to support FTI, that is...
21 #-------------------------------------------------------------------------------
22 package OpenILS::Application::Storage::FTS;
23 use OpenSRF::Utils::Logger qw/:level/;
24 my $log = 'OpenSRF::Utils::Logger';
30 $self = ref($self) || $self;
31 $self = bless {} => $self;
33 $self->decompose($term);
35 my $newterm = join('&', $self->words);
38 $newterm = '('.$newterm.')&('. join('|', $self->nots) . ')';
41 $newterm = OpenILS::Application::Storage->driver->quote($newterm);
43 $self->{fts_query} = ["to_tsquery('default',$newterm)"];
44 $self->{fts_query_nots} = [];
45 $self->{fts_op} = '@@';
52 { # The driver package itself just needs a db_Main method for Class::DBI to call.
53 # any other fixups can go in here too... Also, the drivers should subclass the
54 # DBI driver that they are wrapping, or provide a 'quote()' method that calls
55 # the DBD::xxx::quote() method on FTI's behalf.
57 # The dirver MUST be a subclass of Class::DBI.
58 #-------------------------------------------------------------------------------
59 package OpenILS::Application::Storage::Driver::Pg;
60 use base qw/Class::DBI OpenILS::Application::Storage/;
63 use OpenSRF::Utils::Logger qw/:level/;
65 __PACKAGE__->set_sql( retrieve_limited => 'SELECT * FROM __TABLE__ ORDER BY id LIMIT ?' );
77 return $_dbh if (defined $_dbh and $_dbh->ping);
79 my %attrs = ( %{$self->_default_attributes},
80 RootClass => 'DBIx::ContextualFetch',
81 ShowErrorStatement => 1,
87 FetchHashKeyName => 'NAME_lc',
91 $log->debug(" Default attributes for this DB connection are:\n\t".join("\n\t",map { "$_\t==> $attrs{$_}" } keys %attrs), INTERNAL);
93 $_dbh = DBI->connect( "dbi:Pg:host=$_db_params{host};dbname=$_db_params{database}",$_db_params{user},$_db_params{pw}, \%attrs );
94 $_dbh->do("SET CLIENT_ENCODING TO 'SQL_ASCII';");
100 return $_dbh->quote(@_)
105 #---------------------------------------------------------------------
106 package asset::call_number;
108 __PACKAGE__->table( 'asset.call_number' );
109 __PACKAGE__->sequence( 'asset.call_number_id_seq' );
111 #---------------------------------------------------------------------
114 __PACKAGE__->table( 'asset.copy' );
115 __PACKAGE__->sequence( 'asset.copy_id_seq' );
117 #---------------------------------------------------------------------
118 package biblio::record_entry;
120 __PACKAGE__->table( 'biblio.record_entry' );
121 __PACKAGE__->sequence( 'biblio.record_entry_id_seq' );
123 #---------------------------------------------------------------------
124 package biblio::record_node;
126 __PACKAGE__->table( 'biblio.record_data' );
127 __PACKAGE__->sequence( 'biblio.record_data_id_seq' );
129 #---------------------------------------------------------------------
130 package biblio::record_note;
132 __PACKAGE__->table( 'biblio.record_note' );
133 __PACKAGE__->sequence( 'biblio.record_note_id_seq' );
135 #---------------------------------------------------------------------
138 __PACKAGE__->table( 'actor.usr' );
139 __PACKAGE__->sequence( 'actor.usr_id_seq' );
141 #---------------------------------------------------------------------
142 package actor::org_unit_type;
144 __PACKAGE__->table( 'actor.org_unit_type' );
145 __PACKAGE__->sequence( 'actor.org_unit_type_id_seq' );
147 #---------------------------------------------------------------------