Closed inoc603 closed 1 year ago
I'm conflicted about what to do.
On one hand, I am quite hesitant to include a change in Bob to support older versions of DB engines.
As an example, the MySQL dialect in Bob is strictly for v8.0+ since 5.7 is almost at the EOL.
On the other hand, this seems like a relatively minor change to include.
The feeling's mutual. Maybe we can put aside the 'supporting old DB engines' part, and think of this as generating simpler query for the majority of schemas which have single-column primary key.
Please see https://github.com/stephenafamo/bob/pull/89 for my attempts on this. I'm not sure where should I add tests for this though.
In the refactoring, it seems I have found a way to solve this without too much hassle.
Take a look at the refactor-table-methods branch and try it out.
There are A LOT of breaking changes, and a few things do not fully work yet, that's why #94 is only a draft PR at the moment
Implemented in #94
The current implementation for
DeleteAll
andUpdateAll
uses tuple comparison (I'm not sure what's the right name for it) as primary key condition. So even if a table has a single column primary key, we would still generate queries like this:I'm working with a project that uses some order version of polardb, which does not seem to support conditions like
WHERE (id) in ((?), (?))
. While I'm not asking bob to support every mysql variation out there, maybe we can make the query simpler for tables with single-column primary key?I think all we need is something like this in methods like
DeleteMany
:Is there anything else we need to consider? I'm happy to create a PR for it.