/;
use mro 'c3';
+use Module::Runtime qw(use_module);
use Sub::Name 'subname';
use DBIx::Class::Carp;
use DBIx::Class::Exception;
use Moo;
use namespace::clean;
-has limit_dialect => (is => 'rw', trigger => sub { shift->clear_renderer });
+has limit_dialect => (
+ is => 'rw', default => sub { 'LimitOffset' },
+ trigger => sub { shift->clear_renderer_class }
+);
+
+around _build_renderer_class => sub {
+ my ($orig, $self) = (shift, shift);
+ use_module('Moo::Role')->create_class_with_roles(
+ $self->$orig(@_),
+ 'Data::Query::Renderer::SQL::Slice::'.$self->limit_dialect
+ );
+};
has limit_requires_order_by_stability_check
=> (is => 'rw', default => sub { 0 });
use base qw( DBIx::Class::SQLMaker );
-sub _build_renderer_class {
- Module::Runtime::use_module('Data::Query::Renderer::SQL::SQLite')
-}
+#sub _build_renderer_class {
+# Module::Runtime::use_module('Data::Query::Renderer::SQL::SQLite')
+#}
#
# SQLite does not understand SELECT ... FOR UPDATE
Class::C3::Componentised
Moo
Sub::Quote
+ Module::Runtime
Data::Query::Constants
/, $] < 5.010 ? ( 'Class::C3', 'MRO::Compat' ) : () }; # this is special-cased in DBIx/Class.pm
# based on toplimit.t
delete $schema->storage->_sql_maker->{_cached_syntax};
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::FetchFirst
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('FetchFirst');
$schema->storage->_sql_maker->limit_requires_order_by_stability_check(1);
$schema->storage->_sql_maker->limit_enforces_order_by_stability(1);
my $schema = DBICTest->init_schema;
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::FirstSkip
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('FirstSkip');
my $rs_selectas_col = $schema->resultset ('BooksInLibrary')->search ({}, {
'+select' => ['owner.name'],
my $schema = DBICTest->init_schema;
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::GenericSubquery
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('GenericSubquery');
my $rs = $schema->resultset ('BooksInLibrary')->search ({}, {
'+columns' => [{ owner_name => 'owner.name' }],
my $schema = DBICTest->init_schema;
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::RowNumberOver
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('RowNumberOver');
my $rs_selectas_col = $schema->resultset ('BooksInLibrary')->search ({}, {
'+select' => ['owner.name'],
my $schema = DBICTest->init_schema;
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::RowNum
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('RowNum');
$schema->storage->_sql_maker->limit_requires_order_by_stability_check(1);
my $schema = DBICTest->init_schema;
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::SkipFirst
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('SkipFirst');
my $rs_selectas_col = $schema->resultset ('BooksInLibrary')->search ({}, {
'+select' => ['owner.name'],
# Trick the sqlite DB to use Top limit emulation
# We could test all of this via $sq->$op directly,
# but some conditions need a $rsrc
-$schema->storage->_sql_maker->renderer_class(
- Moo::Role->create_class_with_roles(qw(
- Data::Query::Renderer::SQL::Naive
- Data::Query::Renderer::SQL::Slice::Top
- ))
-);
+$schema->storage->_sql_maker->limit_dialect('Top');
$schema->storage->_sql_maker->limit_requires_order_by_stability_check(1);
$schema->storage->_sql_maker->limit_enforces_order_by_stability(1);