Skip to content
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
- [Read files into DuckDB both spatial and not.][14367]
- [Implement Text_Column to_case for DB backends][14386]
- [Implement bulk loading to DuckDB][14402]
- [Initial file writing from DuckDB][14421]

[13769]: https://github.com/enso-org/enso/pull/13769
[14026]: https://github.com/enso-org/enso/pull/14026
Expand All @@ -100,6 +101,7 @@
[14367]: https://github.com/enso-org/enso/pull/14367
[14386]: https://github.com/enso-org/enso/pull/14386
[14402]: https://github.com/enso-org/enso/pull/14402
[14421]: https://github.com/enso-org/enso/pull/14421

#### Enso Language & Runtime

Expand Down
5 changes: 3 additions & 2 deletions distribution/lib/Standard/Base/0.0.0-dev/docs/api/Error.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
- type Error
- catch self error_type:Standard.Base.Any.Any= handler:Standard.Base.Any.Any= -> Standard.Base.Any.Any
- get_stack_trace_text self -> Standard.Base.Any.Any
- if_not_error self ~other:Standard.Base.Any.Any -> Standard.Base.Any.Any
- if_not_error self ~passthru:Standard.Base.Any.Any -> Standard.Base.Any.Any
- is_error self -> Standard.Base.Any.Any
- map_error self f:Standard.Base.Any.Any -> Standard.Base.Any.Any
- return_if_error flag:Standard.Base.Any.Any -> Standard.Base.Any.Any
- stack_trace self -> Standard.Base.Any.Any
- throw payload:Standard.Base.Any.Any -> Standard.Base.Any.Any
- to_display_text self -> Standard.Base.Any.Any
Expand All @@ -14,6 +15,6 @@
- look_for_wrapped_error error_type:Standard.Base.Any.Any= error_value:Standard.Base.Any.Any -> Standard.Base.Any.Any
- Standard.Base.Any.Any.catch self error_type:Standard.Base.Any.Any= handler:Standard.Base.Any.Any= -> Standard.Base.Any.Any
- Standard.Base.Any.Any.catch_primitive self handler:Standard.Base.Any.Any -> Standard.Base.Any.Any
- Standard.Base.Any.Any.if_not_error self ~other:Standard.Base.Any.Any -> Standard.Base.Any.Any
- Standard.Base.Any.Any.if_not_error self ~passthru:Standard.Base.Any.Any -> Standard.Base.Any.Any
- Standard.Base.Any.Any.is_error self -> Standard.Base.Data.Boolean.Boolean
- Standard.Base.Any.Any.map_error self ~f:Standard.Base.Any.Any -> Standard.Base.Any.Any
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
- to_js_object self -> Standard.Base.Any.Any
- uri self -> Standard.Base.Any.Any
- with_materialized_body self -> Standard.Base.Any.Any
- write self file:Standard.Base.System.File.Generic.Writable_File.Writable_File on_existing_file:Standard.Base.Any.Any= -> Standard.Base.Any.Any
- write self file:Standard.Base.System.File.Generic.Writable_File.Writable_File on_existing_file:Standard.Base.System.File.Existing_File_Behavior.Existing_File_Behavior= -> Standard.Base.Any.Any
- filename_from_content_disposition content_disposition:Standard.Base.Any.Any -> Standard.Base.Any.Any
- resolve_file_metadata_for_response response:Standard.Base.Any.Any -> Standard.Base.Any.Any
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- new input_stream:Standard.Base.Any.Any metadata:Standard.Base.System.File_Format_Metadata.File_Format_Metadata uri:Standard.Base.Network.URI.URI -> Standard.Base.Any.Any
- to_text self -> Standard.Base.Any.Any
- with_stream self action:Standard.Base.Any.Any -> Standard.Base.Any.Any
- write self file:Standard.Base.System.File.Generic.Writable_File.Writable_File on_existing_file:Standard.Base.Any.Any= -> Standard.Base.Any.Any
- write self file:Standard.Base.System.File.Generic.Writable_File.Writable_File on_existing_file:Standard.Base.System.File.Existing_File_Behavior.Existing_File_Behavior= -> Standard.Base.Any.Any
- can_decode type:Standard.Base.Any.Any -> Standard.Base.Any.Any
- decode_format_selector -> Standard.Base.Any.Any
- delete_file file:Standard.Base.Any.Any -> Standard.Base.Any.Any
Expand Down
4 changes: 2 additions & 2 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Data/XML.enso
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ type XML_Document
@path (Widget.Text_Input display=Display.Always)
@encoding Encoding.default_widget
write : Writable_File -> Encoding -> Existing_File_Behavior -> Boolean -> Problem_Behavior -> File
write self path:Writable_File (encoding : Encoding = Encoding.utf_8) (on_existing_file : Existing_File_Behavior = Existing_File_Behavior.Backup) (include_xml_declaration : Boolean = Boolean.True) (on_problems : Problem_Behavior = ..Report_Warning) =
write self path:Writable_File (encoding : Encoding = Encoding.utf_8) (on_existing_file : Existing_File_Behavior = ..Backup) (include_xml_declaration : Boolean = Boolean.True) (on_problems : Problem_Behavior = ..Report_Warning) =
write_impl self.java_document path encoding on_existing_file include_xml_declaration on_problems

## ---
Expand Down Expand Up @@ -783,7 +783,7 @@ type XML_Element
@path (Widget.Text_Input display=Display.Always)
@encoding Encoding.default_widget
write : Writable_File -> Encoding -> Existing_File_Behavior -> Boolean -> Problem_Behavior -> File
write self path:Writable_File (encoding : Encoding = Encoding.utf_8) (on_existing_file : Existing_File_Behavior = Existing_File_Behavior.Backup) (include_xml_declaration : Boolean = Boolean.True) (on_problems : Problem_Behavior = ..Report_Warning) =
write self path:Writable_File (encoding : Encoding = Encoding.utf_8) (on_existing_file : Existing_File_Behavior = ..Backup) (include_xml_declaration : Boolean = Boolean.True) (on_problems : Problem_Behavior = ..Report_Warning) =
write_impl self.java_element path encoding on_existing_file include_xml_declaration on_problems

## ---
Expand Down
35 changes: 28 additions & 7 deletions distribution/lib/Standard/Base/0.0.0-dev/src/Error.enso
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import project.Data.Vector.Vector
import project.Errors.Common.No_Such_Conversion
import project.Errors.Wrapped_Error.Wrapped_Error
import project.Meta
import project.Nothing.Nothing
import project.Panic.Panic
import project.Runtime.Stack_Trace_Element
from project.Data.Boolean import Boolean, False, True
Expand Down Expand Up @@ -207,20 +208,36 @@ type Error
is_error : Boolean
is_error self = True

## ---
private: true
---
A function that will cause an error to be thrown in a Java style
return_if_error : Any -> Nothing
return_if_error flag =
if flag.is_error then flag
Nothing

## ---
advanced: true
icon: warning
---
Returns the provided `other` value, unless `self` is an error.
Returns the provided `passthru` value, unless `self` is an error.

The primary application of this function is to introduce a dataflow
dependency between two otherwise unrelated operations. Very useful if one
of the operations is performing a side-effect.

Aside from ensuring that any dataflow errors are propagated, the result
will also inherit any warnings attached to any of the two inputs.

## Arguments
- `other`: The value to return if `self` is not an error.
- `passthru`: The value to return if `self` is not an error.

## Returns
`passthru` if `self` is not an error; otherwise, returns the error.

## Returns
`passthru` if `self` is not an error; otherwise, returns the error.

## Examples
### Writing to a file and returning the file object if all went well, or an
Expand All @@ -230,8 +247,8 @@ type Error
file.write "foo" . if_not_error file
```
if_not_error : Any -> Any
if_not_error self ~other =
const self other
if_not_error self ~passthru =
const self passthru

## ---
private: true
Expand Down Expand Up @@ -343,16 +360,20 @@ Any.is_error self -> Boolean = False
advanced: true
icon: warning
---
Returns the provided `other` value, unless `self` is an error.
Returns the provided `passthru` value, unless `self` is an error.

The primary application of this function is to introduce a dataflow
dependency between two otherwise unrelated operations. Very useful if one
of the operations is performing a side-effect.

Aside from ensuring that any dataflow errors are propagated, the result
will also inherit any warnings attached to any of the two inputs.

## Arguments
- `other`: The value to return if `self` is not an error.
- `passthru`: The value to return if `self` is not an error.

## Returns
`passthru` if `self` is not an error; otherwise, returns the error.

## Examples
### Writing to a file and returning the file object if all went well, or an
Expand All @@ -361,4 +382,4 @@ Any.is_error self -> Boolean = False
```
file.write "foo" . if_not_error file
```
Any.if_not_error self ~other = other
Any.if_not_error self ~passthru = passthru
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ type Response
```
@file (Widget.Text_Input display=Display.Always)
write : Writable_File -> Existing_File_Behavior -> File
write self file:Writable_File on_existing_file=Existing_File_Behavior.Backup =
write self file:Writable_File on_existing_file:Existing_File_Behavior=..Backup =
self.body.write file on_existing_file

## ---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ type Response_Body
```
@file (Widget.Text_Input display=Display.Always)
write : Writable_File -> Existing_File_Behavior -> File
write self file:Writable_File on_existing_file=Existing_File_Behavior.Backup =
write self file:Writable_File on_existing_file:Existing_File_Behavior=..Backup =
self.with_stream body_stream->
file.write on_existing_file output_stream->
r = output_stream.write_stream body_stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ type URI
```
parse : Text -> URI ! Syntax_Error
parse uri:Text = if uri == "" then Error.throw (Syntax_Error.Error "URI cannot be empty.") else
raw_uri = Panic.catch URISyntaxException (URI.Value (Java_URI.new uri) []) caught_panic->
raw_uri = Panic.catch URISyntaxException (URI.Value (URITransformer.parse uri) []) caught_panic->
query_index = uri.index_of '?'
result = if query_index.is_nothing then Nothing else
new_uri = (uri.take query_index+1) + (URITransformer.encodeQuery (uri.drop query_index+1))
warning = Invalid_Query_String.Warning (uri.drop query_index+1)
Panic.catch URISyntaxException (Warning.attach warning URI.Value (Java_URI.new new_uri) []) _->Nothing
Panic.catch URISyntaxException (Warning.attach warning URI.Value (URITransformer.parse new_uri) []) _->Nothing

if result.is_nothing.not then result else
message = caught_panic.payload.getMessage
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import project.Data.Vector.Vector
import project.Meta
import project.Metadata.Display
import project.Metadata.Widget
from project.Data.Boolean import Boolean, True
Expand Down Expand Up @@ -30,14 +29,13 @@ type Existing_File_Behavior
private: true
---
widget (include_overwrite:Boolean = True) (include_backup:Boolean = True) (include_append:Boolean = True) (include_error:Boolean = True) -> Widget =
fqn = Existing_File_Behavior.to Meta.Type . qualified_name
options = Vector.build builder->
if include_overwrite then
builder.append (Option "Overwrite" fqn+".Overwrite")
builder.append (Option "Overwrite" "..Overwrite")
if include_backup then
builder.append (Option "Backup" fqn+".Backup")
builder.append (Option "Backup" "..Backup")
if include_append then
builder.append (Option "Append" fqn+".Append")
builder.append (Option "Append" "..Append")
if include_error then
builder.append (Option "Error" fqn+".Error")
builder.append (Option "Error" "..Error")
Single_Choice display=Display.Always values=options
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ from project.Metadata import Display, Widget
@path (Widget.Text_Input display=Display.Always)
@encoding Encoding.default_widget
Text.write : Writable_File -> Encoding -> Existing_File_Behavior -> Problem_Behavior -> File ! Encoding_Error | Illegal_Argument | File_Error
Text.write self (path : Writable_File) (encoding : Encoding = Encoding.utf_8) (on_existing_file : Existing_File_Behavior = Existing_File_Behavior.Backup) (on_problems : Problem_Behavior = ..Report_Warning) =
Text.write self (path : Writable_File) (encoding : Encoding = Encoding.utf_8) (on_existing_file : Existing_File_Behavior = ..Backup) (on_problems : Problem_Behavior = ..Report_Warning) =
bytes = self.bytes encoding on_problems
bytes.if_not_error <|
path.write_handling_dry_run on_existing_file effective_file-> stream->
Expand Down Expand Up @@ -97,7 +97,7 @@ Text.write self (path : Writable_File) (encoding : Encoding = Encoding.utf_8) (o
[36, -62, -93, -62, -89, -30, -126, -84, -62, -94].write_bytes Examples.scratch_file.write_bytes Examples.scratch_file Existing_File_Behavior.Append
```
Vector.write_bytes : Writable_File -> Existing_File_Behavior -> Any ! Illegal_Argument | File_Error
Vector.write_bytes self (path : Writable_File) (on_existing_file : Existing_File_Behavior = Existing_File_Behavior.Backup) =
Vector.write_bytes self (path : Writable_File) (on_existing_file : Existing_File_Behavior = ..Backup) =
Panic.catch Unsupported_Argument_Types handler=(_ -> Error.throw (Illegal_Argument.Error "Only Vectors consisting of bytes (integers in the range from -128 to 127) are supported by the `write_bytes` method.")) <|
## Output_Stream does this conversion, but we do it here as well so that
opening a file for a write that will fail won't overwrite existing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- type Connection
- Value jdbc_connection:Standard.Base.Any.Any dialect:Standard.Base.Any.Any type_mapping:Standard.Base.Any.Any entity_naming_properties:Standard.Database.Internal.Connection.Entity_Naming_Properties.Entity_Naming_Properties supports_large_update:(Standard.Base.Runtime.Ref.Ref Standard.Base.Data.Boolean.Boolean) hidden_table_registry:Standard.Database.Internal.Hidden_Table_Registry.Hidden_Table_Registry data_link_setup:(Standard.Database.Internal.Data_Link_Setup.Data_Link_Setup|Standard.Base.Nothing.Nothing)=
- base_connection self -> Standard.Base.Any.Any
- check_on_connection connection:Standard.Base.Any.Any db_table:Standard.Database.DB_Table.DB_Table -> Standard.Base.Any.Any
- close self -> Standard.Base.Any.Any
- column_naming_helper self -> Standard.Base.Any.Any
- create_literal_table self source:Standard.Table.Table.Table alias:Standard.Base.Data.Text.Text -> (Standard.Table.Table.Table&Standard.Database.DB_Table.DB_Table&Standard.Base.Any.Any)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
- fragments self -> Standard.Base.Any.Any
- prepare self -> Standard.Base.Any.Any
- serialize self ensure_roundtrip:Standard.Base.Data.Boolean.Boolean -> Standard.Base.Data.Json.JS_Object!Standard.Database.SQL.Unable_To_Serialize_SQL_Statement
- surround self prefix:Standard.Base.Data.Text.Text= suffix:Standard.Base.Data.Text.Text= -> Standard.Database.SQL.SQL_Statement
- to_js_object self -> Standard.Base.Any.Any
- to_text self -> Standard.Base.Data.Text.Text
- unsafe_to_raw_sql self -> Standard.Base.Any.Any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,17 @@ type Connection
key_column_names = selected.sort 1 . at 0 . to_vector
if key_column_names.is_empty then Nothing else key_column_names

## ---
private: true
---
Checks that the DB_Table is using a specified connection.DB_Table

## Arguments:
- `connection`: Connection to check against
- `db_table`: DB_Table to check
check_on_connection connection db_table:DB_Table =
Meta.is_same_object connection db_table.connection

## ---
private: true
---
Expand Down
16 changes: 16 additions & 0 deletions distribution/lib/Standard/Database/0.0.0-dev/src/SQL.enso
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,22 @@ type SQL_Statement
- `internal_fragments`: A vector of SQL code fragments.
private Value (internal_fragments:(Vector SQL_Fragment))

## ---
private: true
advanced: true
---
Adds a prefix and suffix to the SQL statement.

## Arguments
- `prefix`: The prefix to add.
- `suffix`: The suffix to add.
surround self (prefix : Text = "") (suffix : Text = "") -> SQL_Statement =
if prefix=="" && suffix=="" then self else
prefix_fragment = if prefix=="" then [] else [SQL_Fragment.Code_Part prefix]
suffix_fragment = if suffix=="" then [] else [SQL_Fragment.Code_Part suffix]
new_fragments = prefix_fragment + self.internal_fragments + suffix_fragment
SQL_Statement.Value new_fragments

## ---
private: true
advanced: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@
- schemas self -> Standard.Base.Any.Any
- set_database self database:Standard.Base.Any.Any -> Standard.Base.Any.Any
- set_schema self schema:Standard.Base.Any.Any -> Standard.Base.Any.Any
- spatial_drivers self -> Standard.Base.Any.Any
- table_types self -> Standard.Base.Any.Any
- tables self name_like:Standard.Base.Data.Text.Text= database:Standard.Base.Data.Text.Text= schema:Standard.Base.Data.Text.Text= types:Standard.Base.Any.Any= all_fields:Standard.Base.Any.Any= -> Standard.Base.Any.Any
- to_js_object self -> Standard.Base.Any.Any
- truncate_table self table_name:Standard.Base.Any.Any -> Standard.Base.Any.Any
- type_mapping self -> Standard.Base.Any.Any
- version self -> Standard.Base.Data.Text.Text
- write_database self path:Standard.Base.System.File.Generic.Writable_File.Writable_File= schema_only:Standard.Base.Data.Boolean.Boolean= on_existing_file:Standard.Base.System.File.Existing_File_Behavior.Existing_File_Behavior= -> Standard.Base.Any.Any
- write_file self query:(Standard.Database.SQL_Query.SQL_Query_With_Schema|Standard.Database.SQL_Query.SQL_Query|Standard.Table.Table.Table)= path:Standard.Base.System.File.Generic.Writable_File.Writable_File= on_existing_file:Standard.Base.System.File.Existing_File_Behavior.Existing_File_Behavior= -> Standard.Base.Any.Any
- schema_black_list -> Standard.Base.Any.Any
- Standard.Base.Visualization.Table_Viz_Data.Table_Viz_Data.from that:Standard.DuckDB.DuckDB_Connection.DuckDB_Connection -> Standard.Base.Visualization.Table_Viz_Data.Table_Viz_Data
Loading
Loading