Skip to content

Commit a49c6bc

Browse files
authored
GG-32601 [IGNITE-11528]: Deprecate SqlQuery API (#15)
(cherry picked from commit d7d6d35)
1 parent d075a43 commit a49c6bc

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

pygridgain/api/sql.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16-
"""
17-
Only key-value queries (scan queries) are implemented. SQL part is still
18-
in progress.
19-
"""
2016

2117
from typing import Union
2218

@@ -28,7 +24,7 @@
2824
from pygridgain.datatypes.sql import StatementType
2925
from pygridgain.queries import Query
3026
from pygridgain.queries.op_codes import *
31-
from pygridgain.utils import cache_id
27+
from pygridgain.utils import cache_id, deprecated
3228
from .result import APIResult
3329

3430

@@ -142,6 +138,8 @@ def scan_cursor_get_page(
142138
return result
143139

144140

141+
@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. "
142+
"Use sql_fields instead")
145143
def sql(
146144
conn: 'Connection', cache: Union[str, int],
147145
table_name: str, query_str: str, page_size: int, query_args=None,
@@ -227,6 +225,8 @@ def sql(
227225
return result
228226

229227

228+
@deprecated(version='1.2.0', reason="This API is deprecated and will be removed in the following major release. "
229+
"Use sql_fields instead")
230230
def sql_cursor_get_page(
231231
conn: 'Connection', cursor: int, query_id: int = None,
232232
) -> APIResult:

pygridgain/utils.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#
1616
import ctypes
1717
import decimal
18+
import warnings
19+
1820
from functools import wraps
1921
from threading import Event, Thread
2022
from typing import Any, Callable, Optional, Type, Tuple, Union
@@ -312,3 +314,13 @@ def process_delimiter(name: str, delimiter: str) -> str:
312314
Splits the name by delimiter, capitalize each part, merge.
313315
"""
314316
return ''.join([capitalize(x) for x in name.split(delimiter)])
317+
318+
319+
def deprecated(version, reason):
320+
def decorator_deprecated(fn):
321+
@wraps(fn)
322+
def wrapper_deprecated(*args, **kwds):
323+
warnings.warn(f'Deprecated since {version}. The reason: {reason}', category=DeprecationWarning)
324+
return fn(*args, **kwds)
325+
return wrapper_deprecated
326+
return decorator_deprecated

0 commit comments

Comments
 (0)