simone
simone

Reputation: 5227

How can I use SQL::Abstract's special operators inside DBIx::Class?

I am trying to find a way to use SQL::Abstract's special operators inside DBIx::Class.

My goal is to be able to use sqlite's MATCH operator for full text search so that I can do

$d->search({ textcontent => { -match => "sqlite" }})

to produce a query like this:

SELECT * FROM mail WHERE textcontent MATCH 'sqlite';

I think I can figure out how to do that with SQL::Abstract, but I cannot find how to fiddle with the sql generator inside DBIx::Class. I guess that would be inside DBIx::Class::SQLMaker, though I don't know how I would access that save for subclassing the whole thing.

Upvotes: 0

Views: 165

Answers (1)

hobbs
hobbs

Reputation: 240512

This seems to be undocumented, but one of the "extra attributes" that you can put on a DBIC connect_info (i.e. the arguments to connect) is sql_maker_options. So you can try this out by calling e.g.

$schema->connect($dsn, $username, $password, undef,
    {
        sql_maker_options => {
            special_ops => {
                 ...
            }
        }
    }
);

The SQLMaker is a subclass of SQL::Abstract and should accept the same options unless something says otherwise (and it doesn't).

Upvotes: 1

Related Questions