refactor(query-builder)!: remove logQuery method#12220
refactor(query-builder)!: remove logQuery method#12220pkuczynski wants to merge 1 commit intomasterfrom
Conversation
The logQuery() method (previously printSql) was redundant — all executed queries are already logged automatically through the configured logger. Use getSql() or getQueryAndParameters() to inspect SQL, or enable logging: ["query"] in DataSource options.
Review Summary by QodoRemove redundant logQuery method and update documentation
WalkthroughsDescription• Remove redundant logQuery() method from QueryBuilder • Update migration guide with removal details and alternatives • Enhance query builder docs with SQL inspection examples • Recommend getSql() and DataSource logging configuration Diagramflowchart LR
QB["QueryBuilder<br/>logQuery method"] -- "removed" --> REMOVED["Method removed"]
REMOVED -- "use instead" --> GETSQL["getSql()/<br/>getQueryAndParameters()"]
REMOVED -- "for logging" --> LOGGING["DataSource<br/>logging option"]
DOCS1["Migration Guide"] -- "updated" --> DOCS1_OUT["printSql removed<br/>with alternatives"]
DOCS2["Query Builder Docs"] -- "enhanced" --> DOCS2_OUT["SQL inspection<br/>examples added"]
File Changes1. src/query-builder/QueryBuilder.ts
|
Code Review by Qodo
1. Misdocumented getQuery behavior
|
commit: |
|
Deploying typeorm with
|
| Latest commit: |
1bbad95
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://4752a54a.typeorm.pages.dev |
| Branch Preview URL: | https://refactor-remove-logquery.typeorm.pages.dev |
| ``` | ||
|
|
||
| This query will return users and log the used sql statement through the configured logger. | ||
| `getSql()` returns the SQL with parameter placeholders. `getQuery()` returns the same SQL string. To also see the parameter values, use `getQueryAndParameters()` which returns a `[sql, parameters]` tuple. |
There was a problem hiding this comment.
do getSql() and getQuery() really return the same SQL string?
There was a problem hiding this comment.
No, they do not :)
There's a slight difference: in getSql the query parameters are substituted.
|
@naorpeled I'm going to leave this up to you, since you looked into it before. I remember we also discussed the utility of this function when we chatted about renaming it from Feel free to directly close or merge this PR. |



The
logQuery()method (previouslyprintSql) was redundant — all executed queries are already logged automatically through the configured logger when the query is actually run via QueryRunner. The method was also misleading: it was gated by theloggingDataSource option, so it silently did nothing when logging was disabled (the default).logQuery()fromQueryBuildergetSql()/getQueryAndParameters()for SQL inspection andlogging: ["query"]for automatic query logging