You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please see the details at go-gorm/playground#673 (comment)
This is to implement row level security (RLS) in postgresql, ie each session / connection (or whatever terminology gorm uses) will have a separate session variable value for tenantId but modifying it in one should not impact the value in the others.
An example of how gorm connection pooling can be used to acquire separate connections / sessions which can run in parallel and can have different values of session variables.
The text was updated successfully, but these errors were encountered:
changing a session variable in one session changes it in all the other sessions created out of the same connection. It looks like the gorm Session is not the same as a database session, but something new with the gorm layer.
I can set the session variable directly in the out of of gorm.Open(), there is no need to .Session() it and then create the session variable.
So for now I am doing the following:
create a new gorm.Open() connection for every time I need to set a new session variable
reuse the same connection for unique value of the session variable.
This satisfies the functionality we are trying to achieve via RLS in postgresql while still using gorm.
Your Question
Please see the details at go-gorm/playground#673 (comment)
This is to implement row level security (RLS) in postgresql, ie each session / connection (or whatever terminology gorm uses) will have a separate session variable value for tenantId but modifying it in one should not impact the value in the others.
The underlying code example is https://github.com/go-gorm/playground/pull/673/files#diff-ac94c91f8ea84762d55b6932ef1466a2165984591d3e646360c5bb31b2130900R115-R144
The document you expected this should be explained
https://gorm.io/docs/connecting_to_the_database.html#PostgreSQL
Expected answer
An example of how gorm connection pooling can be used to acquire separate connections / sessions which can run in parallel and can have different values of session variables.
The text was updated successfully, but these errors were encountered: