Skip Menu |
 

This queue is for tickets about the DBIx-DataModel CPAN distribution.

Report information
The Basics
Id: 105812
Status: new
Priority: 0/
Queue: DBIx-DataModel

People
Owner: Nobody in particular
Requestors: aireland [...] lbl.gov
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Quote problem in views
Date: Sat, 11 Jul 2015 14:03:48 -0700
To: bug-DBIx-DataModel [...] rt.cpan.org
From: Amelia Ireland <aireland [...] lbl.gov>
Download (untitled) / with headers
text/plain 1.8k
There is a bug in SQL generation for views that means tables and columns either do not get quoted at all, or they are over-quoted. The following code illustrates the issue: DBIx::DataModel->Schema('DataModel::IMG_Core'); DataModel::IMG_Core->metadm->define_table( class => 'Fruit', db_name => 'FRUIT', primary_key => 'id', ); DataModel::IMG_Core->metadm->define_table( class => 'Taxon', db_name => 'TAXON', primary_key => 'taxon_oid', ); DataModel::IMG_Core ->Association( [qw/Fruit fruit 1 id /], [qw/Taxon taxa * fruit_id /]); DataModel::IMG_Core->metadm->define_table( class => 'FullQuotes', db_name => '"FRUIT" INNER JOIN "TAXON" ON "FRUIT"."id" = "TAXON"."fruit_id"', ); DataModel::IMG_Core->metadm->define_table( class => 'InnerQuotes', db_name => 'FRUIT" INNER JOIN "TAXON" ON "FRUIT"."id" = "TAXON"."fruit_id', ); DataModel::IMG_Core->metadm->define_table( class => 'NoQuotes', db_name => 'FRUIT INNER JOIN TAXON ON FRUIT.id = TAXON.fruit_id', ); # feed the schema with a custom instance of SQL::Abstract::More my $sqlam = SQL::Abstract::More->new(quote_char => '"', name_sep => '.'); DataModel::IMG_Core->singleton->sql_abstract($sqlam); for ('FullQuotes','InnerQuotes','NoQuotes') { my ($sql, @bind) = DataModel::IMG_Core->table($_) ->select( -columns => [ qw( apple banana clementine ) ], -result_as => 'sql', ); say "$_: " . $sql; } Results: FullQuotes: SELECT "apple", "banana", "clementine" FROM """FRUIT"" INNER JOIN ""TAXON"" ON ""FRUIT"""."""id"" = ""TAXON"""."""fruit_id""" InnerQuotes: SELECT "apple", "banana", "clementine" FROM "FRUIT"" INNER JOIN ""TAXON"" ON ""FRUIT"""."""id"" = ""TAXON"""."""fruit_id" NoQuotes: SELECT "apple", "banana", "clementine" FROM "FRUIT INNER JOIN TAXON ON FRUIT"."id = TAXON"."fruit_id"


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.