summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2020-09-08 22:11:29 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2020-09-08 22:11:29 +0000
commit28138ee6fbc1273f1bf16699927e09db81ae7870 (patch)
tree6ff31265f8f975359d24725dee689b9d5d08f14c /lib/sqlalchemy/dialects
parent73fda6d1a85b6245675a05381d79d65685beab18 (diff)
parente8600608669d90c4a6385b312d271aed63eb5854 (diff)
downloadsqlalchemy-28138ee6fbc1273f1bf16699927e09db81ae7870.tar.gz
Merge "Update select usage to use the new 1.4 format"
Diffstat (limited to 'lib/sqlalchemy/dialects')
-rw-r--r--lib/sqlalchemy/dialects/mssql/base.py15
-rw-r--r--lib/sqlalchemy/dialects/oracle/base.py4
-rw-r--r--lib/sqlalchemy/dialects/postgresql/array.py8
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py14
-rw-r--r--lib/sqlalchemy/dialects/postgresql/ext.py4
-rw-r--r--lib/sqlalchemy/dialects/postgresql/hstore.py16
-rw-r--r--lib/sqlalchemy/dialects/postgresql/json.py2
7 files changed, 29 insertions, 34 deletions
diff --git a/lib/sqlalchemy/dialects/mssql/base.py b/lib/sqlalchemy/dialects/mssql/base.py
index ed17fb863..c29fee652 100644
--- a/lib/sqlalchemy/dialects/mssql/base.py
+++ b/lib/sqlalchemy/dialects/mssql/base.py
@@ -296,7 +296,7 @@ For statements that specify only LIMIT and no OFFSET, all versions of SQL
Server support the TOP keyword. This syntax is used for all SQL Server
versions when no OFFSET clause is present. A statement such as::
- select([some_table]).limit(5)
+ select(some_table).limit(5)
will render similarly to::
@@ -306,7 +306,7 @@ For versions of SQL Server prior to SQL Server 2012, a statement that uses
LIMIT and OFFSET, or just OFFSET alone, will be rendered using the
``ROW_NUMBER()`` window function. A statement such as::
- select([some_table]).order_by(some_table.c.col3).limit(5).offset(10)
+ select(some_table).order_by(some_table.c.col3).limit(5).offset(10)
will render similarly to::
@@ -1277,9 +1277,9 @@ class TryCast(sql.elements.Cast):
from sqlalchemy import Numeric
from sqlalchemy.dialects.mssql import try_cast
- stmt = select([
+ stmt = select(
try_cast(product_table.c.unit_price, Numeric(10, 4))
- ])
+ )
The above would render::
@@ -1816,7 +1816,7 @@ class MSSQLCompiler(compiler.SQLCompiler):
mssql_rn = sql.column("mssql_rn")
limitselect = sql.select(
- [c for c in select.c if c.key != "mssql_rn"]
+ *[c for c in select.c if c.key != "mssql_rn"]
)
if offset_clause is not None:
limitselect = limitselect.where(mssql_rn > offset_clause)
@@ -2793,9 +2793,8 @@ class MSDialect(default.DefaultDialect):
@reflection.cache
def get_schema_names(self, connection, **kw):
- s = sql.select(
- [ischema.schemata.c.schema_name],
- order_by=[ischema.schemata.c.schema_name],
+ s = sql.select(ischema.schemata.c.schema_name).order_by(
+ ischema.schemata.c.schema_name
)
schema_names = [r[0] for r in connection.execute(s)]
return schema_names
diff --git a/lib/sqlalchemy/dialects/oracle/base.py b/lib/sqlalchemy/dialects/oracle/base.py
index 65580b4e1..3afd6fc3a 100644
--- a/lib/sqlalchemy/dialects/oracle/base.py
+++ b/lib/sqlalchemy/dialects/oracle/base.py
@@ -1057,7 +1057,7 @@ class OracleCompiler(compiler.SQLCompiler):
# Wrap the middle select and add the hint
inner_subquery = select.alias()
limitselect = sql.select(
- [
+ *[
c
for c in inner_subquery.c
if orig_select.selected_columns.corresponding_column(c)
@@ -1140,7 +1140,7 @@ class OracleCompiler(compiler.SQLCompiler):
limit_subquery = limitselect.alias()
origselect_cols = orig_select.selected_columns
offsetselect = sql.select(
- [
+ *[
c
for c in limit_subquery.c
if origselect_cols.corresponding_column(c)
diff --git a/lib/sqlalchemy/dialects/postgresql/array.py b/lib/sqlalchemy/dialects/postgresql/array.py
index 7fd271d52..dacf1e2c2 100644
--- a/lib/sqlalchemy/dialects/postgresql/array.py
+++ b/lib/sqlalchemy/dialects/postgresql/array.py
@@ -53,9 +53,7 @@ class array(expression.ClauseList, expression.ColumnElement):
from sqlalchemy.dialects import postgresql
from sqlalchemy import select, func
- stmt = select([
- array([1,2]) + array([3,4,5])
- ])
+ stmt = select(array([1,2]) + array([3,4,5]))
print(stmt.compile(dialect=postgresql.dialect()))
@@ -76,11 +74,11 @@ class array(expression.ClauseList, expression.ColumnElement):
recursively adding the dimensions of the inner :class:`_types.ARRAY`
type::
- stmt = select([
+ stmt = select(
array([
array([1, 2]), array([3, 4]), array([column('q'), column('x')])
])
- ])
+ )
print(stmt.compile(dialect=postgresql.dialect()))
Produces::
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 84247d046..e40a730c5 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -572,7 +572,7 @@ SQLAlchemy makes available the PostgreSQL ``@@`` operator via the
method on any textual column expression.
On a PostgreSQL dialect, an expression like the following::
- select([sometable.c.text.match("search string")])
+ select(sometable.c.text.match("search string"))
will emit to the database::
@@ -582,9 +582,7 @@ The PostgreSQL text search functions such as ``to_tsquery()``
and ``to_tsvector()`` are available
explicitly using the standard :data:`.func` construct. For example::
- select([
- func.to_tsvector('fat cats ate rats').match('cat & rat')
- ])
+ select(func.to_tsvector('fat cats ate rats').match('cat & rat'))
Emits the equivalent of::
@@ -594,7 +592,7 @@ The :class:`_postgresql.TSVECTOR` type can provide for explicit CAST::
from sqlalchemy.dialects.postgresql import TSVECTOR
from sqlalchemy import select, cast
- select([cast("some text", TSVECTOR)])
+ select(cast("some text", TSVECTOR))
produces a statement equivalent to::
@@ -615,7 +613,7 @@ In order to provide for this explicit query planning, or to use different
search strategies, the ``match`` method accepts a ``postgresql_regconfig``
keyword argument::
- select([mytable.c.id]).where(
+ select(mytable.c.id).where(
mytable.c.title.match('somestring', postgresql_regconfig='english')
)
@@ -627,7 +625,7 @@ Emits the equivalent of::
One can also specifically pass in a `'regconfig'` value to the
``to_tsvector()`` command as the initial argument::
- select([mytable.c.id]).where(
+ select(mytable.c.id).where(
func.to_tsvector('english', mytable.c.title )\
.match('somestring', postgresql_regconfig='english')
)
@@ -927,7 +925,7 @@ is not available yet in sqlalchemy, however the
:func:`_expression.literal_column` function with the name of the table may be
used in its place::
- select(['*']).select_from(func.my_function(literal_column('my_table')))
+ select('*').select_from(func.my_function(literal_column('my_table')))
Will generate the SQL::
diff --git a/lib/sqlalchemy/dialects/postgresql/ext.py b/lib/sqlalchemy/dialects/postgresql/ext.py
index e64920719..7acab0a0a 100644
--- a/lib/sqlalchemy/dialects/postgresql/ext.py
+++ b/lib/sqlalchemy/dialects/postgresql/ext.py
@@ -22,7 +22,7 @@ class aggregate_order_by(expression.ColumnElement):
from sqlalchemy.dialects.postgresql import aggregate_order_by
expr = func.array_agg(aggregate_order_by(table.c.a, table.c.b.desc()))
- stmt = select([expr])
+ stmt = select(expr)
would represent the expression::
@@ -34,7 +34,7 @@ class aggregate_order_by(expression.ColumnElement):
table.c.a,
aggregate_order_by(literal_column("','"), table.c.a)
)
- stmt = select([expr])
+ stmt = select(expr)
Would represent::
diff --git a/lib/sqlalchemy/dialects/postgresql/hstore.py b/lib/sqlalchemy/dialects/postgresql/hstore.py
index 4e048feb0..cb89f7c5f 100644
--- a/lib/sqlalchemy/dialects/postgresql/hstore.py
+++ b/lib/sqlalchemy/dialects/postgresql/hstore.py
@@ -278,14 +278,14 @@ class hstore(sqlfunc.GenericFunction):
from sqlalchemy.dialects.postgresql import array, hstore
- select([hstore('key1', 'value1')])
-
- select([
- hstore(
- array(['key1', 'key2', 'key3']),
- array(['value1', 'value2', 'value3'])
- )
- ])
+ select(hstore('key1', 'value1'))
+
+ select(
+ hstore(
+ array(['key1', 'key2', 'key3']),
+ array(['value1', 'value2', 'value3'])
+ )
+ )
.. seealso::
diff --git a/lib/sqlalchemy/dialects/postgresql/json.py b/lib/sqlalchemy/dialects/postgresql/json.py
index fbf61dd5f..9ffe9cfe8 100644
--- a/lib/sqlalchemy/dialects/postgresql/json.py
+++ b/lib/sqlalchemy/dialects/postgresql/json.py
@@ -219,7 +219,7 @@ class JSON(sqltypes.JSON):
E.g.::
- select([data_table.c.data['some key'].astext])
+ select(data_table.c.data['some key'].astext)
.. seealso::