-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Disabling SQL compilation cache for Solr releases earlier than 9.0
- Loading branch information
Showing
11 changed files
with
329 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PORT = 8983 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
SOLR_DATE_RANGE_TRANS_RELEASE = 9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import pytest | ||
from sqlalchemy_solr.admin.solr_spec import SolrSpec | ||
|
||
|
||
def assert_solr_release(settings, releases): | ||
solr_spec = SolrSpec(settings["SOLR_BASE_URL"]) | ||
if solr_spec.spec()[0] not in releases: | ||
pytest.skip( | ||
reason=f"Solr spec version {solr_spec} not compatible with the current test" | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from sqlalchemy import select | ||
from sqlalchemy.sql.expression import bindparam | ||
from sqlalchemy.util.langhelpers import _symbol | ||
from tests import assertions | ||
from tests.setup import prepare_orm | ||
|
||
releases = [6, 7, 8] | ||
|
||
|
||
class TestSQLCompilationCaching: | ||
|
||
def test_sql_compilation_caching_1(self, settings): | ||
assertions.assert_solr_release(settings, releases) | ||
|
||
engine, t = prepare_orm(settings) | ||
|
||
qry_1 = (select(t.c.COUNTRY_s).select_from(t)).limit(1) | ||
qry_2 = (select(t.c.COUNTRY_s).select_from(t)).limit(10) | ||
|
||
with engine.connect() as connection: | ||
result_1 = connection.execute(qry_1) | ||
result_2 = connection.execute(qry_2) | ||
|
||
assert result_1.context.cache_hit == _symbol("NO_DIALECT_SUPPORT") | ||
assert result_2.context.cache_hit == _symbol("NO_DIALECT_SUPPORT") | ||
|
||
def test_sql_compilation_caching_2(self, settings): | ||
assertions.assert_solr_release(settings, releases) | ||
|
||
engine, t = prepare_orm(settings) | ||
|
||
qry_1 = (select(t.c.COUNTRY_s).select_from(t)).limit(1).offset(1) | ||
qry_2 = (select(t.c.COUNTRY_s).select_from(t)).limit(1).offset(2) | ||
|
||
with engine.connect() as connection: | ||
result_1 = connection.execute(qry_1) | ||
result_2 = connection.execute(qry_2) | ||
|
||
assert result_1.context.cache_hit == _symbol("NO_DIALECT_SUPPORT") | ||
assert result_2.context.cache_hit == _symbol("NO_DIALECT_SUPPORT") | ||
|
||
def test_sql_compilation_caching_3(self, settings): | ||
assertions.assert_solr_release(settings, releases) | ||
|
||
engine, t = prepare_orm(settings) | ||
|
||
qry = select(t).where(t.c.COUNTRY_s == bindparam("COUNTRY_s")).limit(10) | ||
|
||
with engine.connect() as connection: | ||
result_1 = connection.execute(qry, {"COUNTRY_s": "Sweden"}) | ||
result_2 = connection.execute(qry, {"COUNTRY_s": "France"}) | ||
|
||
assert result_1.context.cache_hit == _symbol("NO_DIALECT_SUPPORT") | ||
assert result_2.context.cache_hit == _symbol("NO_DIALECT_SUPPORT") |
Oops, something went wrong.