jdaugherty commented on PR #16515:
URL: https://github.com/apache/grails-core/pull/16515#issuecomment-6081624949
@matrei Thanks. 34c879e803 addresses all seven points.
1. A lookup by id now returns the instance the session holds for an id when
it belongs to the current tenant, and queries only the other ids. As you
suggested, an instance that is waiting to be inserted and has no tenant id yet
counts as the current tenant's. A new feature in both specs saves one instance
with validation and one with `validate: false` inside `withTransaction`, and
`get`, `exists`, `getAll` and `load` return both before the commit. After the
commit both belong to the current tenant.
2. `withoutId` is now detected from the tenant bound to the thread, through
a new `Tenants.isWithoutId()`, instead of from the resolved id. With a resolver
that returns `DEFAULT`, `get`, `read`, `exists`, `getAll` and `load` agree with
`findById`. A feature in each spec covers it, and another covers
`isWithoutId()` itself.
3. Fixed by 1: `load` returns the held instance, so
`Book.load(book.id).is(book)` is `true` again.
4. `getAll` returns `[]` for no ids before it needs a tenant, as Hibernate
does.
5. Added the feature you described to both specs: the session holds the
other tenant's instance, loaded inside `withTenant('other')`, and `get`,
`read`, `exists`, `getAll` and the proxy don't find it. About the setup:
`Memo.DB` is the `MongoDatabase` (`MongoEntity.getDB()`), not the collection,
so `Memo.DB.drop()` already drops the `NumberedMemo` and `KeyedMemo`
collections with the rest of the database.
6. The id query now runs with the `COMMIT` flush mode, which is restored
afterwards, as in `GormValidationApi.validate`. A lookup by id no longer
flushes. A feature in each spec saves a change, does lookups by id, and then
reads the stored value from a new session. On MongoDB this also stops `getAll`
from flushing. It flushed before this PR, because its lookup by key was already
a query.
7. In upgrade note 19, the flush bullet now says that a lookup by id still
finds an instance the session holds for the current tenant, including one that
was saved but not flushed, and that it doesn't flush. The Hibernate sentence
now says that Hibernate doesn't restrict `load` and `proxy`. The note also says
that `getAll` without ids still returns an empty list.
All five behaviors fail in both specs against 9d47b98435.
`grails-datamapping-core` (251), `grails-datamapping-core-test` (556) and the
MongoDB multi-tenancy, proxy and `getAll` specs (58) pass, and so does
`codeStyle` for both modules.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]