<p dir="auto"><strong>Describe the bug</strong></p>

<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="db.session.query(***) \
            .outerjoin(***, and_(***.model_type_id == ***.id)).filter(
            ***.model_type_id == model_type_id).order_by(
            ***.create_time.desc()).limit(size).offset((page-1)*size).all()
# Same with paginate() "><pre class="notranslate"><span class="pl-s1">db</span>.<span class="pl-s1">session</span>.<span class="pl-en">query</span>(<span class="pl-c1">**</span><span class="pl-c1">*</span>) \
            .<span class="pl-en">outerjoin</span>(<span class="pl-c1">**</span><span class="pl-c1">*</span>, <span class="pl-en">and_</span>(<span class="pl-c1">**</span><span class="pl-c1">*</span>.<span class="pl-s1">model_type_id</span> <span class="pl-c1">==</span> <span class="pl-c1">**</span><span class="pl-c1">*</span>.<span class="pl-s1">id</span>)).<span class="pl-en">filter</span>(
            <span class="pl-c1">**</span><span class="pl-c1">*</span>.<span class="pl-s1">model_type_id</span> <span class="pl-c1">==</span> <span class="pl-s1">model_type_id</span>).<span class="pl-en">order_by</span>(
            <span class="pl-c1">**</span><span class="pl-c1">*</span>.<span class="pl-s1">create_time</span>.<span class="pl-en">desc</span>()).<span class="pl-en">limit</span>(<span class="pl-s1">size</span>).<span class="pl-en">offset</span>((<span class="pl-s1">page</span><span class="pl-c1">-</span><span class="pl-c1">1</span>)<span class="pl-c1">*</span><span class="pl-s1">size</span>).<span class="pl-en">all</span>()
<span class="pl-c"># Same with paginate() </span></pre></div>
<p dir="auto">The parameters of the first run are limit=20, offset=0, no matter what value is passed in limit and offset later, it will not take effect.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/14817376/114850569-7fc33980-9e13-11eb-8468-1a63e7ed8ab3.png"><img src="https://user-images.githubusercontent.com/14817376/114850569-7fc33980-9e13-11eb-8468-1a63e7ed8ab3.png" alt="image" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/14817376/114853180-1f81c700-9e16-11eb-9567-8368954974f9.png"><img src="https://user-images.githubusercontent.com/14817376/114853180-1f81c700-9e16-11eb-9567-8368954974f9.png" alt="image" style="max-width: 100%;"></a><br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/14817376/114853279-345e5a80-9e16-11eb-9019-e5c24db947c9.png"><img src="https://user-images.githubusercontent.com/14817376/114853279-345e5a80-9e16-11eb-9019-e5c24db947c9.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><em>But as long as the first offset is not 0, it can take effect</em></p>
<p dir="auto"><strong>Expected behavior</strong></p>

<p dir="auto">Expect limit and offset to take effect no matter what value is passed<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/14817376/114850452-5acec680-9e13-11eb-8033-f06a93dd2110.png"><img src="https://user-images.githubusercontent.com/14817376/114850452-5acec680-9e13-11eb-8033-f06a93dd2110.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Versions.</strong></p>
<ul dir="auto">
<li>OS: ubuntu18.04</li>
<li>Python: python3.8.5</li>
<li>SQLAlchemy:  Flask-SQLAlchemy         2.4.4</li>
<li>Database: sql server(Microsoft SQL Azure (RTM) - 12.0.2000.8 Feb 20 2021 17:51:58 Copyright (C) 2019 Microsoft Corporation)</li>
<li>DBAPI: {ODBC Driver 17 for SQL Server}</li>
</ul>
<p dir="auto"><strong>Additional context</strong></p>

<p dir="auto"><strong>Have a nice day!</strong></p>
<p dir="auto"><strong>Describe the bug</strong><br>
When using <strong>Microsoft SQL (12.0.2000.8)</strong> <code class="notranslate">OFFSET ? ROWS FETCH FIRST ? ROWS ONLY</code> is wrongly cached.</p>
<ul dir="auto">
<li>If I make query without OFFSET first, and then make query with OFFSET -&gt; i continue to receive results without applying OFFSET.</li>
<li>If I make query with OFFSET first, and then make query without OFFSET -&gt; i receive correct results with correct OFFSET.</li>
</ul>
<p dir="auto"><strong>Expected behavior</strong><br>
No matter in which order I perform queries - queries with and without OFFSET should respect OFFSET.</p>
<p dir="auto"><strong>To Reproduce</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="session.query(Model).offset(0).limit(25).all() # will return [0;24] items
session.query(Model).offset(25).limit(25).all() # will return [0;24] items again"><pre class="notranslate"><code class="notranslate">session.query(Model).offset(0).limit(25).all() # will return [0;24] items
session.query(Model).offset(25).limit(25).all() # will return [0;24] items again
</code></pre></div>
<p dir="auto">but this will work fine after restart</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="session.query(Model).offset(25).limit(25).all() # will return [25;49] items
session.query(Model).offset(0).limit(25).all() # will return [0;24] items"><pre class="notranslate"><code class="notranslate">session.query(Model).offset(25).limit(25).all() # will return [25;49] items
session.query(Model).offset(0).limit(25).all() # will return [0;24] items
</code></pre></div>
<p dir="auto"><strong>Workaround</strong></p>
<p dir="auto">Disabling sql cache fixes the issue</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1628232/114757934-18e74700-9d65-11eb-81f2-14369474f61f.png"><img src="https://user-images.githubusercontent.com/1628232/114757934-18e74700-9d65-11eb-81f2-14369474f61f.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Versions.</strong></p>
<ul dir="auto">
<li>OS: MacOS</li>
<li>Python: 3.7</li>
<li>SQLAlchemy: 1.4.7</li>
<li>Database: MicrosoftSQL</li>
</ul>