RlsPredicateTranspiler
Transpiles LQL row-level security predicates to platform-specific SQL.
Handles the current_user_id() built-in by per-platform substitution
(Postgres: current_setting, SQLite: __rls_context lookup,
SQL Server: SESSION_CONTEXT) and delegates exists(pipeline)
subquery wrappers to the LQL pipeline transpiler.
public static class RlsPredicateTranspiler
Methods
Translate(string, RlsPlatform, string)
public static Result<string, MigrationError> Translate(string lql, RlsPlatform platform, string policyName)
Translate an LQL predicate to platform-specific SQL.
Parameters:
| Name | Type | Description |
|---|---|---|
lql |
String |
LQL predicate. Either a simple expression like |
OwnerId = current_user_id() or an exists(pipeline)
wrapper containing a pipeline. |
| platform | RlsPlatform | Target platform. |
| policyName | String | Policy name -- used for error messages. |
Returns: MigrationError>
CurrentUserIdExpression(RlsPlatform)
public static string CurrentUserIdExpression(RlsPlatform platform)
Returns the platform-specific expression that yields the current user identifier.
Parameters:
| Name | Type | Description |
|---|---|---|
platform |
RlsPlatform |
Returns: String
TranslateGuardPredicate(string, RlsPlatform, string)
public static Result<string, MigrationError> TranslateGuardPredicate(string lql, RlsPlatform platform, string triggerName)
Translate a trigger guard LQL predicate to platform-specific SQL.
Row column references use old./new. prefixes
(case-insensitive) and become platform-quoted OLD./NEW.
references. exists(pipeline) and not exists(pipeline)
subqueries may appear anywhere in the predicate. Predicates containing
the reserved _TRG token are rejected so user literals can
never collide with internal sentinels.
Parameters:
| Name | Type | Description |
|---|---|---|
lql |
String |
LQL guard predicate. |
platform |
RlsPlatform |
Target platform. |
triggerName |
String |
Trigger name -- used for error messages. |
Returns: MigrationError>