summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2023-03-04 16:31:18 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2023-03-04 16:31:18 +0000
commitb7ff13a6d70ce2990892c08947cf12131d2213cf (patch)
treeee54d114066be2cf956c70ec8447bdc2dc73d37f /lib/sqlalchemy/sql
parentb561b0f8ee877301ef264ed31a288fbd6b315e41 (diff)
parentc39dc697c1598c4a6a934dc0b5a60a0eaae6555d (diff)
downloadsqlalchemy-b7ff13a6d70ce2990892c08947cf12131d2213cf.tar.gz
Merge "Add missing overload to Numeric" into main
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r--lib/sqlalchemy/sql/functions.py14
-rw-r--r--lib/sqlalchemy/sql/sqltypes.py20
2 files changed, 27 insertions, 7 deletions
diff --git a/lib/sqlalchemy/sql/functions.py b/lib/sqlalchemy/sql/functions.py
index 6054be98a..5f2e67288 100644
--- a/lib/sqlalchemy/sql/functions.py
+++ b/lib/sqlalchemy/sql/functions.py
@@ -13,6 +13,7 @@
from __future__ import annotations
import datetime
+import decimal
from typing import Any
from typing import cast
from typing import Dict
@@ -54,7 +55,6 @@ from .elements import WithinGroup
from .selectable import FromClause
from .selectable import Select
from .selectable import TableValuedAlias
-from .sqltypes import _N
from .sqltypes import TableValueType
from .type_api import TypeEngine
from .visitors import InternalTraversal
@@ -950,7 +950,7 @@ class _FunctionGenerator:
...
@property
- def cume_dist(self) -> Type[cume_dist[Any]]:
+ def cume_dist(self) -> Type[cume_dist]:
...
@property
@@ -1014,7 +1014,7 @@ class _FunctionGenerator:
...
@property
- def percent_rank(self) -> Type[percent_rank[Any]]:
+ def percent_rank(self) -> Type[percent_rank]:
...
@property
@@ -1703,7 +1703,7 @@ class dense_rank(GenericFunction[int]):
inherit_cache = True
-class percent_rank(GenericFunction[_N]):
+class percent_rank(GenericFunction[decimal.Decimal]):
"""Implement the ``percent_rank`` hypothetical-set aggregate function.
This function must be used with the :meth:`.FunctionElement.within_group`
@@ -1715,11 +1715,11 @@ class percent_rank(GenericFunction[_N]):
"""
- type: sqltypes.Numeric[_N] = sqltypes.Numeric()
+ type: sqltypes.Numeric[decimal.Decimal] = sqltypes.Numeric()
inherit_cache = True
-class cume_dist(GenericFunction[_N]):
+class cume_dist(GenericFunction[decimal.Decimal]):
"""Implement the ``cume_dist`` hypothetical-set aggregate function.
This function must be used with the :meth:`.FunctionElement.within_group`
@@ -1731,7 +1731,7 @@ class cume_dist(GenericFunction[_N]):
"""
- type: sqltypes.Numeric[_N] = sqltypes.Numeric()
+ type: sqltypes.Numeric[decimal.Decimal] = sqltypes.Numeric()
inherit_cache = True
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py
index 3c6cb0cb5..458394870 100644
--- a/lib/sqlalchemy/sql/sqltypes.py
+++ b/lib/sqlalchemy/sql/sqltypes.py
@@ -470,6 +470,26 @@ class Numeric(HasExpressionLookup, TypeEngine[_N]):
_default_decimal_return_scale = 10
+ @overload
+ def __init__(
+ self: Numeric[decimal.Decimal],
+ precision: Optional[int] = ...,
+ scale: Optional[int] = ...,
+ decimal_return_scale: Optional[int] = ...,
+ asdecimal: Literal[True] = ...,
+ ):
+ ...
+
+ @overload
+ def __init__(
+ self: Numeric[float],
+ precision: Optional[int] = ...,
+ scale: Optional[int] = ...,
+ decimal_return_scale: Optional[int] = ...,
+ asdecimal: Literal[False] = ...,
+ ):
+ ...
+
def __init__(
self,
precision: Optional[int] = None,