@@ -2746,18 +2746,24 @@ type DB_Table
2746
2746
2747
2747
Some operations, like writing to tables, require their target to be a
2748
2748
trivial query.
2749
- is_trivial_query self -> Boolean ! Table_Not_Found =
2749
+
2750
+ Arguments:
2751
+ - fail_if_not_found: If `True`, a `Table_Not_Found` error is raised if the
2752
+ table does not exist in the database. Otherwise, `False` is returned.
2753
+ is_trivial_query self (fail_if_not_found : Boolean = True) -> Boolean ! Table_Not_Found =
2750
2754
case self.context.from_spec of
2751
2755
From_Spec.Table internal_table_name _ _ ->
2752
2756
if self.name != internal_table_name then False else
2753
2757
trivial_counterpart = self.connection.query (SQL_Query.Table_Name self.name)
2754
2758
# If the table spec seems trivial, but the underlying table does not exist, we propagate the Table_Not_Found error.
2755
- trivial_counterpart.if_not_error <|
2759
+ check_context_and_columns =
2756
2760
if self.context != trivial_counterpart.context then False else
2757
2761
column_descriptor internal_column = [internal_column.name, internal_column.expression]
2758
2762
my_columns = self.internal_columns.map column_descriptor
2759
2763
trivial_columns = trivial_counterpart.internal_columns.map column_descriptor
2760
2764
my_columns == trivial_columns
2765
+ if fail_if_not_found then trivial_counterpart.if_not_error check_context_and_columns else
2766
+ if trivial_counterpart.is_error then False else check_context_and_columns
2761
2767
_ -> False
2762
2768
2763
2769
## PRIVATE
0 commit comments