Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: "m.cavalletto@xxxxxxxxx" <m.cavalletto@xxxxxxxxx>
- Date: 11 Jul 2005 15:36:05 -0700
> Suppose I was writing a system that would allow me to write
> portable queries.
Again, I'd urge you to build on one of the existing efforts in this
area.
> So would it be possible to add such functionality to
> DBIx::SQLEngine -- the ability to analyze the parts of an existing
> query and identify each one and potentially modify it?
Yes -- in fact, it's already doing some of the basics of this. For
example, the DBIx::SQLEngine interface already supports portability
adaptors for joins, limits, unions, and other non-standard features.
Each query is built up from data structures into a SQL string and
parameters by a Driver object with automatic subclassing based on DBD
type. Applications can assemble, review, and modify a query as a hash
of parameters, and then send it off to the driver to get turned into a
locally ideosyncratic SQL string.
(Of course, applications can define their own SQL in some other way and
pass it through without any modification; the translation process
typically only applies when you've asked the driver to generate queries
from parameters.)
I'd be entirely open to a DBIx::SQLEngine patch that automatically
rewrote "CONCAT(col1, col2)" to "col1 || col2" when buidling queries
for Postgres. (I think this could be done in the sql_select and
sql_where methods of the DBIx::SQLEngine::Driver::Pg class.)
Generalizing from that, it should be reasonably straightforward to
build a table of various common functions with indications of whether
they're supported and what syntax is required on various platforms.
Ultimately, some functions may not be supported on some drivers --
you'll never be able to make DBD::CSV act like Postgres and Oracle --
but you can provide a capability interface that reports whether or not
a given feature is available, and provide a helpful error message if an
application tries to use a feature not supported on a given platform.
Patches welcome...
On the other hand, if you find DBIx::SQLEngine's flexible options
procesing insufficiently rigorous, try taking a look at Rosetta and
SQL::Routine. Like your proposed syntax, they're focused on building
and maintaining trees representing the structure of various queries...
I think the result is a little too unwieldy for my purposes, but you
might find it useful.
-Simon
.
- References:
- Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: sebastian
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: Ron Savage
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: sebastian
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: Dean Arnold
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: sebastian
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: sebastian
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: m.cavalletto@xxxxxxxxx
- Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- From: sebastian
- Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- Prev by Date: Re: Calling External DLL functions in Perl using Inline
- Next by Date: Re: Calling External DLL functions in Perl using Inline
- Previous by thread: Re: Reusing SQL data-related logic, replacing weird modules and improving Class::DBI
- Next by thread: [ANNOUNCE] Win32::Console::ANSI v1.0
- Index(es):
Relevant Pages
|
Loading