DBIx::C...SQLMaker(3)
π DBIx::C...SQLMaker(3) β like, the whole vibe β¨
Okay bestie, welcome to DBIx::C...SQLMaker(3), part of the User Contributed Perl Documentation situation. Buckle up, this one's a whole lore drop π«Ά
β¨ NAME β¨
DBIx::Class::SQLMaker β an SQL::Abstract::Classic-like SQL maker class. That's it, that's the name, no cap π
πΈ DESCRIPTION πΈ
So this module is literally just a "nexus class" β its whole job is giving SQL::Abstract::Classic-like functionality to DBIx::Class itself, and to a bunch of database-engine-specific subclasses. That's the tea β
And the way this indirection is explicitly maintained? Not an accident, bestie β it's on purpose, so you can swap out the core of SQL generation inside DBIC on a per-$schema basis without major architectural changes. No big dramatic refactor, no crying, just vibes β¨
And it's guaranteed by design and tests that this fast-switching will keep being maintained indefinitely. Iconic behavior honestly π
π¦ Implementation switching π¦
See "connect_call_rebase_sqlmaker" in DBIx::Class::Storage::DBI. That's where the switching magic lives, iykyk π
π₯ ROADMAP π₯
Some maintainer musings on the current state of SQL generation within DBIC, as of October 2019. Grab a snack, this is a long one π
π§ Folding of most (or all) of SQL::Abstract::Classic (SQLAC) into DBIC π§
So the rise of complex prefetch use, plus the general streamlining of result parsing within DBIC, ended up pushing actual SQL generation straight to the forefront of many casual performance profiles. Main character energy, truly π
The idea behind the SQLAC-like API is sound, but the actual implementation is terribly inefficient β once again bumping into the ridiculously high overhead of perl function calls π
Given that SQLAC has a very distinct life of its own, and will hopefully continue to be used within an order of magnitude more projects compared to DBIC, it is prudent to not disturb the current call chains within SQLAC itself. Instead, in the future an effort will be undertaken to seek a more thorough decoupling of DBIC SQL generation from reliance on SQLAC β possibly to a point where in the future DBIC may no longer depend on SQL::Abstract::Classic at all π³β¨
The SQL::Abstract::Classic library itself will continue being maintained, although it is not likely to gain many extra features. Notably, it will NOT add further dialect support β at least not within the preexisting SQL::Abstract::Classic namespace. Read that again, bestie, it's a hard no π
Such streamlining work (if undertaken) will take into consideration the following constraints:
π Main API compatibility π
The object returned by $schema->storage->sqlmaker needs to be able to satisfy most of the basic tests found in the current-at-the-time SQLAC dist. While things like case or logic or even worse convert will definitely remain unsupported, the rest of the tests should pass β within reason, okay? We're not miracle workers π
π Ability to replace SQL::Abstract::Classic with a derivative module π
During the initial work on Data::Query, which later was slated to occupy the preexisting namespace of SQL::Abstract, the test suite of DBIC turned out to be an invaluable asset for ironing out hard-to-reason-about corner cases. In addition, the test suite is much more vast and intricate than the tests of SQLAC itself. This state of affairs is way too valuable to sacrifice just to gain faster SQL generation π₯
So the SQLMaker rebase functionality introduced in DBIC v0.082850, along with extra CI configurations, will continue to ensure that DBIC can be used with an off-the-CPAN SQLAC and derivatives, and that it continues to flawlessly run its entire test suite. While this will undoubtedly complicate the future implementation of a better performing SQL generator, it will preserve both the usability of the test suite for external projects and will keep SQL::Abstract::Classic from regressions in the future. Win-win, we love to see it π«Ά
Aside from these constraints, it's becoming more and more practical to simply stop using SQLAC in day-to-day production deployments of DBIC. The flexibility of the internals is simply not worth the performance cost. Sorry not sorry π
π§ Relationship to SQL::Abstract and what formerly was known as Data::Query (DQ) π§
When initial work on DQ was taking place, the tools in ::Storage::DBIHacks (https://github.com/Perl5/DBIx-Class/blob/master/lib/DBIx/Class/Storage/DBIHacks.pm) were only beginning to take shape, and it wasn't clear how important they'd become further down the road. In fact, the regexing all over the place was considered an ugly stop-gap β and even a couple of highly entertaining talks were given to that effect π iconic honestly
As the use-cases of DBIC were progressing, and evidence for the importance of supporting arbitrary SQL was mounting, it became clearer that DBIC itself would not really benefit in any significant way from tighter integration with DQ β but on the contrary is likely to lose crucial functionality (https://github.com/Perl5/DBIx-Class/blob/7ef1a09ec4/lib/DBIx/Class/Storage/DBIHacks.pm#L373-L396) while the corners of the brand new DQ/SQLA codebase are sanded off. Oop π«
The current stance on DBIC/SQLA integration is that it would mainly benefit SQLA by having access to the very extensive "early adopter" test suite β in the same manner as early DBIC benefitted tremendously from usurping the Class::DBI test suite. As far as the DBIC user-base goes, there are no immediate large-scale upsides to deep SQLA integration, neither in terms of API nor in performance. As such, it is unlikely that DBIC will switch back to using SQL::Abstract in its core any time soon β if ever. Periodt π
Accordingly, the DBIC development effort will in the foreseeable future ignore the existence of the new-guts SQLA, and will continue optimizing the preexisting SQLAC-based solution β potentially "organically growing" its own compatible implementation π±β¨
Also, as described higher up, the ability to plug a separate SQLAC-compatible class providing the necessary surface API will remain possible, and will be protected at all costs in order to continue providing SQLA and friends access to the test cases of DBIC. We ride at dawn for that test suite π«Ά
π FURTHER QUESTIONS? π
Check the list of additional DBIC resources. Go look, bestie, the answers are out there π
π COPYRIGHT AND LICENSE π
This module is free software copyright by the DBIx::Class (DBIC) authors. You can redistribute it and/or modify it under the same terms as the DBIx::Class library. Slay, legally speaking β¨
And that's the whole page, bestie! This masterpiece came to you courtesy ofperl v5.42.0, dated2025-01-22, and the header/footer wereDBIx::C...SQLMaker(3)all along π Mwah, go forth and generate SQL πΈ
π¦ where this page comes from
- opensuse-leap 16.0: perl-DBIx-Class 0.082844-bp160.1.10 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms