This commit is contained in:
Beto Dealmeida
2026-05-08 14:12:46 -04:00
parent af2d3babec
commit 0fe8293c7f
8 changed files with 24 additions and 74 deletions

View File

@@ -1285,42 +1285,6 @@ def test_start_oauth2_dance_falls_back_to_url_for(mocker: MockerFixture) -> None
assert error.extra["redirect_uri"] == fallback_uri
def test_get_rls_method_default_subquery() -> None:
"""
By default, an engine that supports subqueries and aliases-in-select
uses the safer subquery RLS strategy.
"""
class _Spec(BaseEngineSpec):
allows_subqueries = True
allows_alias_in_select = True
assert _Spec.get_rls_method() == RLSMethod.AS_SUBQUERY
def test_get_rls_method_default_predicate_when_no_subqueries() -> None:
"""
Engines without subquery / alias-in-select support fall back to the
AST predicate strategy.
"""
class _Spec(BaseEngineSpec):
allows_subqueries = False
allows_alias_in_select = True
assert _Spec.get_rls_method() == RLSMethod.AS_PREDICATE
def test_get_rls_method_class_attribute_override() -> None:
"""
Setting ``rls_method`` on an engine spec opts the engine into a specific
strategy regardless of the subquery/alias defaults — used by engines whose
sqlglot dialect can parse but not faithfully regenerate SQL.
"""
class _SpliceSpec(BaseEngineSpec):
allows_subqueries = True
allows_alias_in_select = True
rls_method = RLSMethod.AS_PREDICATE_SPLICE
assert _SpliceSpec.get_rls_method() == RLSMethod.AS_PREDICATE_SPLICE
def test_default_rls_method_is_subquery() -> None:
"""Base engine spec defaults to subquery-based RLS."""
assert BaseEngineSpec.rls_method == RLSMethod.AS_SUBQUERY