Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
AdRiley committed Oct 8, 2024
1 parent 98b964f commit b6d3f13
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1014,12 +1014,12 @@ type DB_Table

resolved = case value of
_ : Text -> self.make_constant_column value
_ : Expression -> Feature.Set.if_supported_else_throw self.connection.dialect "set" <| self.evaluate_expression value on_problems
_ : Expression -> Feature.Set_From_Expression.if_supported_else_throw self.connection.dialect "set from expression" <| self.evaluate_expression value on_problems
_ : DB_Column ->
if Helpers.check_integrity self value then value else
Error.throw (Integrity_Error.Error "Column "+value.name)
_ : Constant_Column -> self.make_constant_column value
_ : Simple_Expression -> Feature.Set.if_supported_else_throw self.connection.dialect "set" <| value.evaluate self (set_mode==Set_Mode.Update && as=="") on_problems
_ : Simple_Expression -> Feature.Set_From_Expression.if_supported_else_throw self.connection.dialect "set from expression" <| value.evaluate self (set_mode==Set_Mode.Update && as=="") on_problems
_ : Vector -> Error.throw (Unsupported_Database_Operation "`Vector` for `set`")
_ : Array -> Error.throw (Unsupported_Database_Operation.Error "`Array` for `set`")
_ : Range -> Error.throw (Unsupported_Database_Operation.Error "`Range` for `set`")
Expand Down Expand Up @@ -1073,7 +1073,7 @@ type DB_Table
an `Additional_Warnings`.
evaluate_expression : Text | Expression -> Problem_Behavior -> DB_Column ! No_Such_Column | Invalid_Value_Type | Expression_Error
evaluate_expression self expression:(Text | Expression) on_problems:Problem_Behavior=..Report_Warning =
Feature.Set.if_supported_else_throw self.connection.dialect "evaluate_expression" <|
Feature.Set_From_Expression.if_supported_else_throw self.connection.dialect "evaluate_expression" <|
if expression.is_a Text then self.evaluate_expression (Expression.Value expression) on_problems else
get_column name = self.at name
make_constant_column value = case value of
Expand Down
4 changes: 2 additions & 2 deletions distribution/lib/Standard/Database/0.0.0-dev/src/Feature.enso
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ type Feature
currently blocks getting a DB_Column from a DB_Table, but will soon refine to operations on DB_Column.
Column_Operations
## PRIVATE
set operations on tables.
Set
set from expression operations on tables. Other set types should always be possible.
Set_From_Expression
## PRIVATE
get_row, take, drop, limit
Sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ from project.Common_Table_Operations.Util import all
main filter=Nothing = run_default_backend add_specs filter

add_specs suite_builder setup =
if setup.is_feature_supported Feature.Set then (add_derived_columns_specs suite_builder setup) else
if setup.is_feature_supported Feature.Set_From_Expression then (add_derived_columns_specs suite_builder setup) else
suite_builder.group setup.prefix+"(Derived_Columns_Spec) Table.set" group_builder->
group_builder.specify "set should report unsupported" <|
table_builder = setup.light_table_builder
t1 = table_builder [["X", [1, 2, 3]], ["Y", [4, 5, 6]]]
t2 = t1.set (Simple_Expression.Simple_Expr (Column_Ref.Name "A") Simple_Calculation.Copy) "C"
t2.should_fail_with (Unsupported_Database_Operation.Error "set")
t2.should_fail_with (Unsupported_Database_Operation.Error "set from expression")

add_derived_columns_specs suite_builder setup =
prefix = setup.prefix
Expand Down

0 comments on commit b6d3f13

Please sign in to comment.