-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support OF
in locking clause
#285
Comments
Hi @mattdowdell, |
@go-jet Is there a workaround I can use to inject |
No, I don't see other workaround. |
@go-jet I had a stab at implementing this, but got myself mixed up trying to figure out how. As it stands, RowLock's are part of the internal jet package, so extending the implementation there seems to be simplest. Particularly as that's where serialisation occurs today. I also added an extra interface/constructor (RowLockOf) so the method did not leak to the mysql or sqlite packages, e.g. package jet
type RowLockOf interface {
RowLock
OF(table ...X) RowLock
}
func NewRowLockOf(name string) func() RowLockOf {
// ...
} The problem came when figuring out how to pass the tables into the OF clause. I assume I want postgres.ReadableTable as an argument, but that would cause a circular import. Would you be able provide some advice on how to tie it off and/or whether it's a viable implementation? |
Agree.
There is no need for new interface. We want
You don't need the whole |
Is your feature request related to a problem? Please describe.
I have a query doing LEFT JOIN across 2 tables modeled on a many-to-many relationship and locking rows to prevent concurrent updates.
My schema is as follows, minus some rows I trimmed out for simplification:
In essence I can have multiple resources and each resource can have multiple groups associated with it.
I then have an update API that executes a SQL query as follows:
This produces an error:
This in itself seems to be expected per https://www.postgresql.org/message-id/21634.1160151923@sss.pgh.pa.us. And it's likely I need to rethink my use of joins in general.
On the plus side, I found that adjusting the locking clause to:
FOR UPDATE OF resources NOWAIT;
Allows the query to work. However, this does not seem to be supported in jet, potentially becaise this seems to be a PostgeSQL specific feature.
Describe the solution you'd like
Support the use of
OF
inpostgres.RowLock
to allow outer joins to use locks.In testing the revised query, I found that the table in the
OF
clause had to be justresources
and the use ofpublic.resources
as used in theFROM
clause did not work.The text was updated successfully, but these errors were encountered: