Skip to content

Commit

Permalink
read table by name, SQL_Query
Browse files Browse the repository at this point in the history
  • Loading branch information
GregoryTravis committed Jan 30, 2025
1 parent ba7eb71 commit a0774e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ type Generic_JDBC_Connection
read self sql_query:SQL_Query -> Table =
resolved_sql = case sql_query of
SQL_Query.Raw_SQL raw_sql -> raw_sql
SQL_Query.Table_Name table_name -> "select * from "+(self.quote table_name)
SQL_Query.Table_Name table_name -> "select * from "+(self.quote_identifier table_name)

self.jdbc_connection.with_prepared_statement resolved_sql Statement_Setter.default stmt->
rs = stmt.executeQuery
Expand All @@ -112,7 +112,6 @@ type Generic_JDBC_Connection
table = result_set_to_table rs make_fallback_fetcher
SQL_Warning_Helper.process_warnings stmt <|
table
-

## ALIAS catalog schema database
GROUP Standard.Base.Metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from Standard.Test import all

import Standard.Database.Errors.SQL_Error
import Standard.Database.JDBC.Generic_JDBC_Connection.Generic_JDBC_Connection
import project.SQL_Query.SQL_Query
import Standard.Database.SQL_Query.SQL_Query

add_specs suite_builder =
data_dir = enso_project.data / "transient"
Expand Down Expand Up @@ -180,11 +180,11 @@ add_specs suite_builder =
conn.execute "insert into bar (c, d) values (20, 'qqqq')"
conn.execute "insert into bar (c, d) values (30, 'zzzz')"

r = conn.read (SQL_Query.Table_Name "foo")
r = conn.read (SQL_Query.Table_Name "FOO")
r.at "A" . to_vector . should_equal [10, 20]
r.at "B" . to_vector . should_equal ['asdf', 'zxcv']

r2 = conn.read (SQL_Query.Table_Name "bar")
r2 = conn.read (SQL_Query.Table_Name "BAR")
r2.at "C" . to_vector . should_equal [20, 30]
r2.at "D" . to_vector . should_equal ['qqqq', 'zzzz']

Expand Down

0 comments on commit a0774e7

Please sign in to comment.