Skip to content

Commit cae6fd8

Browse files
committed
more tweaking
1 parent 1400bdc commit cae6fd8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

distribution/lib/Standard/Database/0.0.0-dev/src/DB_Table.enso

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,18 +2746,24 @@ type DB_Table
27462746

27472747
Some operations, like writing to tables, require their target to be a
27482748
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 =
27502754
case self.context.from_spec of
27512755
From_Spec.Table internal_table_name _ _ ->
27522756
if self.name != internal_table_name then False else
27532757
trivial_counterpart = self.connection.query (SQL_Query.Table_Name self.name)
27542758
# 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 =
27562760
if self.context != trivial_counterpart.context then False else
27572761
column_descriptor internal_column = [internal_column.name, internal_column.expression]
27582762
my_columns = self.internal_columns.map column_descriptor
27592763
trivial_columns = trivial_counterpart.internal_columns.map column_descriptor
27602764
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
27612767
_ -> False
27622768

27632769
## PRIVATE

distribution/lib/Standard/Database/0.0.0-dev/src/Internal/DB_Data_Link_Helpers.enso

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ save_table_as_data_link table destination on_existing_file:Existing_File_Behavio
2424
Error.throw (Illegal_Argument.Error "Saving a Table as data link is currently not supported in this backend.")
2525

2626
# For a trivial query we return the table name.
27-
link_type = if table.is_trivial_query then ..Table table.name else
27+
link_type = if table.is_trivial_query fail_if_not_found=False then ..Table table.name else
2828
sql_statement = table.to_sql
2929
prepared = sql_statement.prepare
3030
# If there are no interpolations, we can do a raw query represented by Text (more friendly in the GUI).

0 commit comments

Comments
 (0)