Hey Tim,

I really like this new feature—thanks for making it happen! It reminds me of 
the fluent SQL builder[1] that Owen presented at the 2014 Architecture 
Summit.[2] While integration with that library was ultimately rejected, I 
wonder if there are any useful concepts or features that could be cherry-picked 
from there to enhance the functionality of MediaWiki’s new query builder.

What do you think?

—
[1] https://github.com/Wikia/fluent-sql-php
[2] https://www.mediawiki.org/wiki/Architecture_Summit_2014/SQL_abstraction

Cheers,
Máté Szabó 
SOFTWARE ENGINEER
he - him - his

Fandom Poland sp. z o.o. z siedzibą w Poznaniu, ul. Abp. A. Baraniaka 6
Sąd Rejonowy Poznań – Nowe Miasto i Wilda w Poznaniu, VIII Wydział Gospodarczy 
Krajowego Rejestru Sądowego, KRS 0000254365
NIP: 5252358778
Kapitał zakładowy: 50.000,00 złotych

> On 22 May 2020, at 03:37, Tim Starling <[email protected]> wrote:
> 
> SelectQueryBuilder is a new fluent interface for constructing database
> queries, which has been merged to master for release in MediaWiki
> 1.35. Please consider using it in new code.
> 
> SELECT page_id FROM page
> WHERE page_namespace=$namespace AND page_title=$title
> 
> becomes
> 
> $id = $db->newSelectQueryBuilder()
>   ->select( 'page_id' )
>   ->from( 'page' )
>   ->where( [
>      'page_namespace' => $namespace,
>      'page_title' => $title,
>   ] )
>   ->fetchField();
> 
> As explained on the design task T243051, SelectQueryBuilder was
> loosely based on the query builder in Doctrine, but I made an effort
> to respect existing MediaWiki conventions, to make migration easy.
> 
> SelectQueryBuilder is easy to use for simple cases, but has the most
> impact on readability when it is used for complex queries. That's why
> I chose to migrate the showIndirectLinks query in
> Special:WhatLinksHere as a pilot -- it was one of the gnarliest
> queries in core.
> 
> SelectQueryBuilder excels at building joins, including parenthesized
> (nested) joins and joins on subqueries.
> 
> SelectQueryBuilder can be used as a structured alternative to the
> "query info" pattern, in which the parameters to Database::select()
> are stored in an associative array. It can convert to and from such
> arrays. As a pilot of this functionality, I converted ApiQueryBase to
> use a SelectQueryBuilder to store accumulated query info.
> 
> Check it out!
> 
> -- Tim Starling
> 
> 
> _______________________________________________
> Wikitech-l mailing list
> [email protected]
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l


_______________________________________________
Wikitech-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Reply via email to