summaryrefslogtreecommitdiff
path: root/test/sql/test_tablesample.py
diff options
context:
space:
mode:
authorsaarni <saarni@gmail.com>2016-05-26 10:52:24 +0300
committersaarni <saarni@gmail.com>2016-05-26 10:52:24 +0300
commitc2feaa98ed374151d40a85fa52344de8ec87dad6 (patch)
tree186d961e2c0fe5f2ceed04fb2ad7552e010d8f05 /test/sql/test_tablesample.py
parentd9f3571ebf51523bff16c8d228817dbfbf285728 (diff)
downloadsqlalchemy-pr/277.tar.gz
Changed how TableSample handles method and arg.pr/277
Instead of passing a float percentage and a string method, accept either a non Function value wrapped in func.system, or a Function, which is rendered as is.
Diffstat (limited to 'test/sql/test_tablesample.py')
-rw-r--r--test/sql/test_tablesample.py14
1 files changed, 7 insertions, 7 deletions
diff --git a/test/sql/test_tablesample.py b/test/sql/test_tablesample.py
index 6c21f1173..5470e1748 100644
--- a/test/sql/test_tablesample.py
+++ b/test/sql/test_tablesample.py
@@ -1,6 +1,6 @@
from sqlalchemy.testing import fixtures
from sqlalchemy.testing import AssertsCompiledSQL, assert_raises_message
-from sqlalchemy.sql import select, func
+from sqlalchemy.sql import select, func, text
from sqlalchemy.engine import default
from sqlalchemy import exc
from sqlalchemy import Table, Integer, String, Column
@@ -28,26 +28,26 @@ class TableSampleTest(fixtures.TablesTest, AssertsCompiledSQL):
# context of a FROM clause
self.assert_compile(
tablesample(table1, 1, name='alias'),
- 'people AS alias TABLESAMPLE SYSTEM(1)'
+ 'people AS alias TABLESAMPLE system(:system_1)'
)
self.assert_compile(
table1.sample(1, name='alias'),
- 'people AS alias TABLESAMPLE SYSTEM(1)'
+ 'people AS alias TABLESAMPLE system(:system_1)'
)
self.assert_compile(
- tablesample(table1, 1, name='alias', method='BERNOULLI',
+ tablesample(table1, func.bernoulli(1), name='alias',
seed=func.random()),
- 'people AS alias TABLESAMPLE BERNOULLI(1) REPEATABLE (random())'
+ 'people AS alias TABLESAMPLE bernoulli(:bernoulli_1) REPEATABLE (random())'
)
def test_select_from(self):
table1 = self.tables.people
self.assert_compile(
- select([table1.sample(1, name='alias').c.people_id]),
+ select([table1.sample(text('1'), name='alias').c.people_id]),
'SELECT alias.people_id FROM '
- 'people AS alias TABLESAMPLE SYSTEM(1)'
+ 'people AS alias TABLESAMPLE system(1)'
)