-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update rename_columns
to new API design, add first_row
, second_row
and last_row
functions to the table.
#5719
Conversation
rename_columns
to new API design, add first_row
, second_row
and last_row
functions to the table.
distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Table_Helpers.enso
Outdated
Show resolved
Hide resolved
7625859
to
51b8f2c
Compare
Removing Table_Helpers dependency on the Matchers.
420d559
to
69a5d55
Compare
69a5d55
to
cc262ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
distribution/lib/Standard/Database/0.0.0-dev/src/Data/Table.enso
Outdated
Show resolved
Hide resolved
distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Connection.enso
Outdated
Show resolved
Hide resolved
last_row : Row ! Index_Out_Of_Bounds | ||
last_row self = | ||
if self.internal_columns.is_empty then Error.throw (Illegal_Argument.Error "Cannot create a table with no columns.") else | ||
sql = self.to_sql | ||
expected_types = self.internal_columns.map .sql_type | ||
self.connection.read_statement sql expected_types True . rows . first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is done in completely different way than the others. I'm wondering if we shouldn't revisit this once we get take
/drop
, so that we can use more consistent code for all cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes I think when we come to take/drop
we will want to do something cleverer.
column_builders = column_types.map create_builder | ||
case last_row_only of | ||
True -> | ||
## Not using the `ResultSet.last` as not supported by all connection types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really appreciate the comment!
fetch_and_append self rs i = | ||
value = self.fetch_value rs i | ||
self.append value | ||
|
||
## PRIVATE | ||
Fetches the value of ith column from the current row of the result set | ||
fetch_value : ResultSet -> Integer -> Any | ||
fetch_value self rs i = | ||
value = case self of | ||
Builder.Builder_Inferred _ -> rs.getObject i | ||
Builder.Builder_Boolean _ -> rs.getBoolean i | ||
Builder.Builder_Long _ -> rs.getLong i | ||
Builder.Builder_Double _ -> rs.getDouble i | ||
if rs.wasNull then Nothing else value | ||
|
||
## PRIVATE | ||
append : Any -> Nothing | ||
append self value = if value.is_nothing then self.java_builder.appendNulls 1 else | ||
case self of | ||
Builder.Builder_Inferred _ -> self.java_builder.append value | ||
Builder.Builder_Boolean _ -> self.java_builder.appendBoolean value | ||
Builder.Builder_Long _ -> self.java_builder.appendLong value | ||
Builder.Builder_Double _ -> self.java_builder.appendDouble value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks so much cleaner! 🙂
distribution/lib/Standard/Table/0.0.0-dev/src/Internal/Table_Helpers.enso
Outdated
Show resolved
Hide resolved
…egex_matcher-and-update-the-column-selectors
Pull Request Description
rename_columns
API.first_row
,second_row
andlast_row
to the Table types.Notes
ResultSet.last
as SQLite doesn't support scrollable cursors so went for iterative approach.["A","B"].contains
wouldn't work for some reason.Checklist
Please include the following checklist in your PR:
Scala,
Java,
and
Rust
style guides.
./run ide build
and./run ide watch
.