summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/schema.py
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2021-04-05 21:57:24 +0200
committerMike Bayer <mike_mp@zzzcomputing.com>2021-04-06 17:18:44 -0400
commit3de954bc027ebf655e7ed26c83cfb3fd4b7b5edf (patch)
tree207b479aee69c640acb4143567fe882084ec1d0c /lib/sqlalchemy/sql/schema.py
parent165c3a65dcb1ba3f42ecf2b5da7c298bdc259f9b (diff)
downloadsqlalchemy-3de954bc027ebf655e7ed26c83cfb3fd4b7b5edf.tar.gz
Table arguments name and metadata are positional only
The :class:`_sql.Table` object now raises an informative error message if it is instantiated without passing at least the :paramref:`_sql.Table.name` and :paramref:`_sql.Table.metadata` arguments positionally. Previously, if these were passed as keyword arguments, the object would silently fail to initialize correctly. Fixes: #6135 Change-Id: I54d0c89fd549fc504289a87ea0bb37369f982b06
Diffstat (limited to 'lib/sqlalchemy/sql/schema.py')
-rw-r--r--lib/sqlalchemy/sql/schema.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/sqlalchemy/sql/schema.py b/lib/sqlalchemy/sql/schema.py
index 9d7617370..f2c1c86ec 100644
--- a/lib/sqlalchemy/sql/schema.py
+++ b/lib/sqlalchemy/sql/schema.py
@@ -546,14 +546,17 @@ class Table(DialectKWArgs, SchemaItem, TableClause):
),
)
def __new__(cls, *args, **kw):
- if not args:
+ if not args and not kw:
# python3k pickle seems to call this
return object.__new__(cls)
try:
name, metadata, args = args[0], args[1], args[2:]
except IndexError:
- raise TypeError("Table() takes at least two arguments")
+ raise TypeError(
+ "Table() takes at least two positional-only "
+ "arguments 'name' and 'metadata'"
+ )
schema = kw.get("schema", None)
if schema is None: