Replies: 1 comment 2 replies
-
I don't recall when we added the PR welcome 👍 It will be a bit more work than just using the |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First, just want to say I am a huge fan of this library, it is very well done and thank you for the hard work making this for the community.
Describe the bug
I have a question about understanding how connection type is being decided and the
preferReadReplica
option. We wanted to gradually start adopting a read replica for certain queries in our app so wanted to leverage thepreferReadReplica: false
to selectively choose which queries would start using it. It appears that this option wasn't respected when using query builder, because we were hitting the read replica when none of our queries should have been using it.Since we use the PostgresSqlDriver, it seems like the connectionType is not specified when using createQueryBuilder from the EntityManager.
It seems the createQueryBuilder function in AbstractSqlDriver respects these options when calling
resolveConnectionType
mikro-orm/packages/knex/src/AbstractSqlDriver.ts
Lines 871 to 880 in 5a24ced
but when calling it from the SqlEntityManager, the connectionType remains undefined
mikro-orm/packages/knex/src/SqlEntityManager.ts
Lines 15 to 19 in 5a24ced
which means it could can take on a read connection in
execute
mikro-orm/packages/knex/src/query/QueryBuilder.ts
Line 643 in 5a24ced
Happy to put up a fix if this is indeed an issue, but wanted to make sure I'm tracing this out correctly first or if there is something I missed.
To Reproduce
Steps to reproduce the behavior:
preferReadReplica
to falseExpected behavior
Would expect that the preferReadReplica is respected using the query builder
Versions
Beta Was this translation helpful? Give feedback.
All reactions