cakephp / phinx

PHP Database Migrations for Everyone
https://phinx.org
MIT License
4.46k stars 892 forks source link

getQueryBuilder and documentation for 0.15? #2238

Closed wallacio closed 10 months ago

wallacio commented 10 months ago

Where is the "official" documentation for 0.15?

We've been using 0.13.x for some time now, for which there's great documentation at https://book.cakephp.org/phinx/0/en/index.html.

A recent composer update (amongst other things) has bumped phinx to the 0.15.x release. There are a few breaking changes introduced here, some of which are documented and which I have resolved locally. What I struggled with in particular is working out how getQueryBuilder() works. For starters, it requires a parameter for the query type (e.g. 'select', 'update' etc.) https://github.com/cakephp/phinx/blob/ccbb7f2b4bf1297fec64447d1f4a773f5d9455e0/src/Phinx/Db/Adapter/AdapterInterface.php#L288

Typehinting is also wrong; whilst getQueryBuilder() returns Cake\Database\Query, the IDE doesn't recognise methods belonging to the relevant child class, for example Cake\Database\UpdateQuery which has the methods update() and set():

image

Whilst I appreciate that this typehinting is probably an issue with cakephp\database, it would be great to see some official documentation for 0.15 detailing these changes. There is of course every chance that I'm now using getQueryBuilder incorrectly but I can't see the alternative.

wallacio commented 10 months ago

Taking inspiration from cakephp/database, why not replace the getQueryBuilder(string $type) method with type-specific methods, returning the appropriate data type?

e.g. for an INSERT statement,

function getQueryBuilder('insert'): Query

would be replaced with

function getInsertBuilder(): InsertQuery

dereuromark commented 10 months ago

PR open