This repository was archived by the owner on Mar 6, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 326
This repository was archived by the owner on Mar 6, 2026. It is now read-only.
Equal operator in table constraints class throws error when instance in None #2174
Copy link
Copy link
Closed
Labels
api: bigqueryIssues related to the googleapis/python-bigquery API.Issues related to the googleapis/python-bigquery API.
Description
Equal operator in table constraints class throws error when instance in None
Code issue equal operator
class TableConstraints:
"""The TableConstraints defines the primary key and foreign key.
Args:
primary_key:
Represents a primary key constraint on a table's columns. Present only if the table
has a primary key. The primary key is not enforced.
foreign_keys:
Present only if the table has a foreign key. The foreign key is not enforced.
"""
def __init__(
self,
primary_key: Optional[PrimaryKey],
foreign_keys: Optional[List[ForeignKey]],
):
self.primary_key = primary_key
self.foreign_keys = foreign_keys
def __eq__(self, other):
if not isinstance(other, TableConstraints) and other is not None:
raise TypeError("The value provided is not a BigQuery TableConstraints.")
return (
self.primary_key == other.primary_key if other.primary_key else None
) and (self.foreign_keys == other.foreign_keys if other.foreign_keys else None)```
#### Stack tracefix
class TableConstraints:
"""The TableConstraints defines the primary key and foreign key.
Args:
primary_key:
Represents a primary key constraint on a table's columns. Present only if the table
has a primary key. The primary key is not enforced.
foreign_keys:
Present only if the table has a foreign key. The foreign key is not enforced.
"""
def __init__(
self,
primary_key: Optional[PrimaryKey],
foreign_keys: Optional[List[ForeignKey]],
):
self.primary_key = primary_key
self.foreign_keys = foreign_keys
def __eq__(self, other):
if not isinstance(other, TableConstraints) and other is not None:
raise TypeError("The value provided is not a BigQuery TableConstraints.")
return (
self.primary_key == other.primary_key if other and other.primary_key else None
) and (self.foreign_keys == other.foreign_keys if other.foreign_keys else None)
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: bigqueryIssues related to the googleapis/python-bigquery API.Issues related to the googleapis/python-bigquery API.