11"""Provides classes for performing a table diff
22"""
33
4- from abc import ABC , abstractmethod
54import time
65import os
76from numbers import Number
1312
1413from runtype import dataclass
1514
16- from .sql import Select , Checksum , Compare , DbPath , DbKey , DbTime , Count , TableName , Time , Min , Max , Value
15+ from .sql import Select , Checksum , Compare , DbPath , DbKey , DbTime , Count , TableName , Time , Value
1716from .utils import safezip , split_space
1817from .databases .base import Database
1918from .databases .database_types import (
@@ -50,6 +49,9 @@ class TableSegment:
5049 max_key (:data:`DbKey`, optional): Highest key_column value, used to restrict the segment
5150 min_update (:data:`DbTime`, optional): Lowest update_column value, used to restrict the segment
5251 max_update (:data:`DbTime`, optional): Highest update_column value, used to restrict the segment
52+ where (str, optional): An additional 'where' expression to restrict the search space.
53+
54+ case_sensitive (bool): If false, the case of column names will adjust according to the schema. Default is true.
5355
5456 """
5557
@@ -68,6 +70,7 @@ class TableSegment:
6870 min_update : DbTime = None
6971 max_update : DbTime = None
7072
73+ where : str = None
7174 case_sensitive : bool = True
7275 _schema : Schema = None
7376
@@ -114,7 +117,7 @@ def _normalize_column(self, name: str, template: str = None) -> str:
114117 return self .database .normalize_value_by_type (col , col_type )
115118
116119 def with_schema (self ) -> "TableSegment" :
117- "Queries the table schema from the database, and returns a new instance of TableSegmentWithSchema ."
120+ "Queries the table schema from the database, and returns a new instance of TableSegment, with a schema ."
118121 if self ._schema :
119122 return self
120123
@@ -149,7 +152,12 @@ def _make_update_range(self):
149152 def _make_select (self , * , table = None , columns = None , where = None , group_by = None , order_by = None ):
150153 if columns is None :
151154 columns = [self ._normalize_column (self .key_column )]
152- where = list (self ._make_key_range ()) + list (self ._make_update_range ()) + ([] if where is None else [where ])
155+ where = [
156+ * self ._make_key_range (),
157+ * self ._make_update_range (),
158+ * ([] if where is None else [where ]),
159+ * ([] if self .where is None else [self .where ]),
160+ ]
153161 order_by = None if order_by is None else [order_by ]
154162 return Select (
155163 table = table or TableName (self .table_path ),
0 commit comments