diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-07-11 19:40:59 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2021-07-11 19:40:59 -0400 |
commit | 2aae37f93b413176d683259e0bc712728af931db (patch) | |
tree | 8b46b2b4e60998a3131040be32c66a6d54cd93b3 /lib/sqlalchemy/sql/selectable.py | |
parent | ca52e87268fec966f6005b1e4aa30206ae895e9e (diff) | |
download | sqlalchemy-2aae37f93b413176d683259e0bc712728af931db.tar.gz |
represent tablesample.sampling as FunctionElement in all cases
Fixed regression where the :func:`_sql.tablesample` construct would fail to
be executable when constructed given a floating-point sampling value not
embedded within a SQL function.
Fixes: #6735
Change-Id: I557bcd4bdbffc4329ad69d5659ba99b1c8deb554
Diffstat (limited to 'lib/sqlalchemy/sql/selectable.py')
-rw-r--r-- | lib/sqlalchemy/sql/selectable.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/selectable.py b/lib/sqlalchemy/sql/selectable.py index 235c74ea7..42cb6e5ae 100644 --- a/lib/sqlalchemy/sql/selectable.py +++ b/lib/sqlalchemy/sql/selectable.py @@ -1970,18 +1970,18 @@ class TableSample(AliasedReturnsRows): sampling, name=name, seed=seed ) + @util.preload_module("sqlalchemy.sql.functions") def _init(self, selectable, sampling, name=None, seed=None): + functions = util.preloaded.sql_functions + if not isinstance(sampling, functions.Function): + sampling = functions.func.system(sampling) + self.sampling = sampling self.seed = seed super(TableSample, self)._init(selectable, name=name) - @util.preload_module("sqlalchemy.sql.functions") def _get_method(self): - functions = util.preloaded.sql_functions - if isinstance(self.sampling, functions.Function): - return self.sampling - else: - return functions.func.system(self.sampling) + return self.sampling class CTE( |