Skip to content

Commit

Permalink
CR
Browse files Browse the repository at this point in the history
  • Loading branch information
radeusgd committed Apr 28, 2023
1 parent fe55ce4 commit dad7666
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ type Connection
@types make_table_types_selector
@schema make_schema_selector
tables : Text -> Text -> Text -> Vector -> Boolean -> Materialized_Table
tables self name_like=Nothing database=self.database schema=Nothing types=default_table_types all_fields=False =
tables self name_like=Nothing database=self.database schema=Nothing types=self.dialect.default_table_types all_fields=False =
types_array = if types.is_nothing then Nothing else types.to_array
name_map = Map.from_vector [["TABLE_CAT", "Database"], ["TABLE_SCHEM", "Schema"], ["TABLE_NAME", "Name"], ["TABLE_TYPE", "Type"], ["REMARKS", "Description"], ["TYPE_CAT", "Type Database"], ["TYPE_SCHEM", "Type Schema"], ["TYPE_NAME", "Type Name"]]
self.jdbc_connection.with_metadata metadata->
Expand Down Expand Up @@ -235,11 +235,6 @@ type Connection
drop_table self table_name =
self.execute_update (self.dialect.generate_sql (Query.Drop_Table table_name))

## ADVANCED
The default types we want to include in `tables`.
default_table_types =
["TABLE", "VIEW", "TEMPORARY TABLE", "TEMPORARY VIEW", "MATERIALIZED VIEW", "FOREIGN TABLE", "PARTITIONED TABLE", "GLOBAL TEMPORARY"]

## PRIVATE
make_table_types_selector connection =
Single_Choice values=(connection.table_types.map t-> Option t t.pretty)
Expand All @@ -251,7 +246,7 @@ make_schema_selector connection =

## PRIVATE
all_known_table_names connection =
tables = connection.tables name_like=Nothing database=connection.database schema=Nothing types=default_table_types all_fields=False
tables = connection.tables name_like=Nothing database=connection.database schema=Nothing types=Nothing all_fields=False
tables.at "Name" . to_vector

## PRIVATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ type Dialect
_ = operation
Unimplemented.throw "This is an interface only."

## PRIVATE
The default table types to use when listing tables.
default_table_types : Vector Text
default_table_types self =
Unimplemented.throw "This is an interface only."

## PRIVATE

The dialect of SQLite databases.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import project.Internal.IR.Query.Query
import project.Internal.JDBC_Connection
import project.Internal.SQL_Type_Reference.SQL_Type_Reference

from project.Connection.Connection import default_table_types, make_table_types_selector, make_schema_selector, make_table_name_selector
from project.Connection.Connection import make_table_types_selector, make_schema_selector, make_table_name_selector
from project.Errors import SQL_Error
from project.Internal.Result_Set import read_column

Expand Down Expand Up @@ -102,7 +102,7 @@ type Postgres_Connection
@types make_table_types_selector
@schema make_schema_selector
tables : Text -> Text -> Text -> Vector -> Boolean -> Materialized_Table
tables self name_like=Nothing database=self.database schema=Nothing types=default_table_types all_fields=False =
tables self name_like=Nothing database=self.database schema=Nothing types=self.dialect.default_table_types all_fields=False =
self.connection.tables name_like database schema types all_fields

## Set up a query returning a Table object, which can be used to work with data within the database or load it into memory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ type Postgres_Dialect
is_supported self operation =
self.internal_generator_dialect.is_supported operation

## PRIVATE
The default table types to use when listing tables.
default_table_types : Vector Text
default_table_types self =
["TABLE", "VIEW", "TEMPORARY TABLE", "TEMPORARY VIEW", "MATERIALIZED VIEW", "FOREIGN TABLE", "PARTITIONED TABLE"]

## PRIVATE
make_internal_generator_dialect =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,9 @@ type Redshift_Dialect
is_supported : Text -> Boolean
is_supported self operation =
self.internal_generator_dialect.is_supported operation

## PRIVATE
The default table types to use when listing tables.
default_table_types : Vector Text
default_table_types self =
["TABLE", "VIEW", "TEMPORARY TABLE", "TEMPORARY VIEW", "MATERIALIZED VIEW", "FOREIGN TABLE", "PARTITIONED TABLE"]
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import project.Internal.IR.Query.Query
import project.Internal.JDBC_Connection
import project.Internal.SQL_Type_Reference.SQL_Type_Reference

from project.Connection.Connection import default_table_types, make_table_types_selector, make_schema_selector, make_table_name_selector
from project.Connection.Connection import make_table_types_selector, make_schema_selector, make_table_name_selector
from project.Errors import SQL_Error

type SQLite_Connection
Expand Down Expand Up @@ -96,7 +96,7 @@ type SQLite_Connection
@types make_table_types_selector
@schema make_schema_selector
tables : Text -> Text -> Text -> Vector -> Boolean -> Materialized_Table
tables self name_like=Nothing database=self.database schema=Nothing types=default_table_types all_fields=False =
tables self name_like=Nothing database=self.database schema=Nothing types=self.dialect.default_table_types all_fields=False =
self.connection.tables name_like database schema types all_fields

## Set up a query returning a Table object, which can be used to work with data within the database or load it into memory.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@ type SQLite_Dialect
is_supported self operation =
self.internal_generator_dialect.is_supported operation

## PRIVATE
The default table types to use when listing tables.
default_table_types : Vector Text
default_table_types self =
["TABLE", "VIEW", "GLOBAL TEMPORARY"]


## PRIVATE
make_internal_generator_dialect =
Expand Down

0 comments on commit dad7666

Please sign in to comment.