Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ap/dbix-simple-concrete

monkey-patch DBIx::Simple to use SQL::Concrete
https://github.com/ap/dbix-simple-concrete

dbix perl sql

Last synced: 11 days ago
JSON representation

monkey-patch DBIx::Simple to use SQL::Concrete

Awesome Lists containing this project

README

        

use 5.006; use strict; use warnings;

package DBIx::Simple::Concrete;

our $VERSION = '1.007';

use DBIx::Simple ();
use SQL::Concrete ();

sub import {
shift;
my $prelude = sprintf qq'package %s;\n#line %d "%s"\n', ( caller )[0,2,1];
my $sub = eval qq{ sub { $prelude SQL::Concrete->import(\@_) } };
&$sub;
}

sub cquery { shift->query( SQL::Concrete::Renderer->new->render( @_ ) ) }

die 'Too late to patch DBIx::Simple' if DBIx::Simple->can( 'cquery' );

*DBIx::Simple::cquery = \&cquery;

__END__

=pod

=encoding UTF-8

=head1 NAME

DBIx::Simple::Concrete - monkey-patch DBIx::Simple to use SQL::Concrete

=head1 SYNOPSIS

use DBIx::Simple::Concrete;
# ...
my $rows = $db->cquery( '
SELECT title
FROM threads
WHERE date >', \$date, '
AND', { subject => \@subjects }, '
' )->arrays;

=head1 DESCRIPTION

The recommended way to use L is via its L
integration, which provides an excellent alternative to plain DBI access.

But by loading this module instead (or after) L, a C
method will be added to it which integrates L just the same
way as its built-in C method integrates L.

This is all there is to this module.

=cut