Skip to content

Commit 1400bdc

Browse files
committed
further tweaking to is_trivial_query
1 parent e0efc3c commit 1400bdc

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

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

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,13 +2747,18 @@ type DB_Table
27472747
Some operations, like writing to tables, require their target to be a
27482748
trivial query.
27492749
is_trivial_query self -> Boolean ! Table_Not_Found =
2750-
trivial_counterpart = self.connection.query (SQL_Query.Table_Name self.name)
2751-
if trivial_counterpart.is_error then False else
2752-
if self.context != trivial_counterpart.context then False else
2753-
column_descriptor internal_column = [internal_column.name, internal_column.expression]
2754-
my_columns = self.internal_columns.map column_descriptor
2755-
trivial_columns = trivial_counterpart.internal_columns.map column_descriptor
2756-
my_columns == trivial_columns
2750+
case self.context.from_spec of
2751+
From_Spec.Table internal_table_name _ _ ->
2752+
if self.name != internal_table_name then False else
2753+
trivial_counterpart = self.connection.query (SQL_Query.Table_Name self.name)
2754+
# 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 <|
2756+
if self.context != trivial_counterpart.context then False else
2757+
column_descriptor internal_column = [internal_column.name, internal_column.expression]
2758+
my_columns = self.internal_columns.map column_descriptor
2759+
trivial_columns = trivial_counterpart.internal_columns.map column_descriptor
2760+
my_columns == trivial_columns
2761+
_ -> False
27572762

27582763
## PRIVATE
27592764
Provides a simplified text representation for display in the REPL and errors.

test/Table_Tests/src/Database/Upload_Spec.enso

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ add_specs suite_builder setup make_new_connection persistent_connector=True =
518518
db_table_3 = db_table_1.aggregate ["X"] [Aggregate_Column.Sum (expr "[Y]*[Y]") "C3"] . set (expr "[X] + 1") "X"
519519

520520
db_table_4 = db_table_2.join db_table_3 join_kind=Join_Kind.Left_Outer
521-
db_table_4.is_trivial_query . should_fail_with Table_Not_Found
521+
db_table_4.is_trivial_query . should_be_false
522522

523523
copied_table = db_table_4.select_into_database_table data.connection (Name_Generator.random_name "copied-table") temporary=True primary_key=Nothing
524524
copied_table.column_names . should_equal ["X", "Y", "C1", "C2", "Right X", "C3"]

0 commit comments

Comments
 (0)