Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ type Redshift_Details

# TODO [RW] can we inherit these from postgres?
encoding = parse_postgres_encoding (get_encoding_name jdbc_connection)
entity_naming_properties = Entity_Naming_Properties.from_jdbc_connection jdbc_connection encoding is_case_sensitive=True

Connection.new jdbc_connection Redshift_Dialect.redshift Postgres_Type_Mapping entity_naming_properties
Connection.new jdbc_connection Redshift_Dialect.redshift Postgres_Type_Mapping (Entity_Naming_Properties.from_jdbc_connection jdbc_connection encoding is_case_sensitive=True)

## ---
private: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ from Standard.Base.Metadata.Choice import Option
from Standard.Base.Metadata.Widget import File_Browse, Single_Choice, Text_Input, Vector_Editor

import Standard.Table.Internal.Column_Naming_Helper.Column_Naming_Helper
import Standard.Table.Internal.Unique_Name_Strategy.Unique_Name_Strategy
import Standard.Table.Rows_To_Read.Rows_To_Read
from Standard.Table import Table

Expand All @@ -27,7 +28,6 @@ import project.Internal.JDBC_Connection.JDBC_Connection
import project.Internal.SQL_Type_Reference.SQL_Type_Reference
import project.Internal.SQL_Warning_Helper
import project.Internal.Statement_Setter.Statement_Setter
import project.Internal.Table_Naming_Helper.Table_Naming_Helper
import project.SQL.SQL_Statement
import project.SQL.SQL_Type
import project.SQL_Query.SQL_Query
Expand Down Expand Up @@ -66,7 +66,15 @@ type Connection
to the user, but are used internally by the dry-run system.
- `data_link_setup`: an optional setup allowing for saving the connection
as a data link.
Value jdbc_connection dialect type_mapping (statement_setter:Statement_Setter) (entity_naming_properties : Entity_Naming_Properties) (supports_large_update : Ref Boolean) (hidden_table_registry : Hidden_Table_Registry.Hidden_Table_Registry) (data_link_setup : Data_Link_Setup | Nothing = Nothing)
Value
jdbc_connection
dialect
type_mapping
(statement_setter:Statement_Setter)
(~entity_naming_properties)
(supports_large_update : Ref Boolean)
(hidden_table_registry : Hidden_Table_Registry.Hidden_Table_Registry)
(data_link_setup : Data_Link_Setup | Nothing = Nothing)

## ---
private: true
Expand All @@ -88,7 +96,7 @@ type Connection
`executeLargeUpdate`.
- `statement_setter`: a helper for setting parameters on prepared
statements.
new jdbc_connection:JDBC_Connection dialect type_mapping entity_naming_properties:Entity_Naming_Properties (data_link_setup : Data_Link_Setup | Nothing = Nothing) (try_large_update : Boolean = True) (statement_setter : Statement_Setter = Statement_Setter.default) -> Connection =
new jdbc_connection:JDBC_Connection dialect type_mapping ~entity_naming_properties (data_link_setup : Data_Link_Setup | Nothing = Nothing) (try_large_update : Boolean = True) (statement_setter : Statement_Setter = Statement_Setter.default) -> Connection =
registry = Hidden_Table_Registry.new
Connection.Value jdbc_connection dialect type_mapping statement_setter entity_naming_properties (Ref.new try_large_update) registry data_link_setup

Expand Down Expand Up @@ -510,23 +518,6 @@ type Connection
Hidden_Table_Registry.run_maintenance_table_cleanup self
self.jdbc_connection.run_maintenance_action_if_possible callback

## ---
private: true
---
Returns a helper for checking and generating table names.
table_naming_helper : Table_Naming_Helper
table_naming_helper self = Table_Naming_Helper.Value self

## ---
private: true
---
Returns a helper for checking and generating column names.
column_naming_helper : Column_Naming_Helper
column_naming_helper self =
column_naming_properties = self.entity_naming_properties.for_column_names
generated_column_naming_properties = self.entity_naming_properties.for_generated_column_names
Column_Naming_Helper.Value column_naming_properties generated_column_naming_properties

## ---
private: true
---
Expand Down Expand Up @@ -675,3 +666,19 @@ get_tables_advanced jdbc_connection name_like:Text|Nothing database:Text|Nothing
renamed = table.rename_columns name_dict error_on_missing_columns=False on_problems=..Ignore
if all_fields then renamed else
renamed.select_columns ["Database", "Schema", "Name", "Type", "Description"]

## ---
private: true
---
Converts a Connection to a Column_Naming_Helper
Column_Naming_Helper.from (that:Connection) =
column_naming_properties = that.entity_naming_properties.for_column_names
generated_column_naming_properties = that.entity_naming_properties.for_generated_column_names
Column_Naming_Helper.Value column_naming_properties generated_column_naming_properties

## ---
private: true
---
Converts a Connection to a column Unique_Name_Strategy
Unique_Name_Strategy.from (that:Connection) =
Unique_Name_Strategy.new that.entity_naming_properties.for_column_names
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ type Postgres_Connection
quoted we have full case sensitivity and can distinguish columns
`A` from `a` as different.
Our generator is supposed to always quote identifiers
entity_naming_properties = Entity_Naming_Properties.from_jdbc_connection jdbc_connection encoding is_case_sensitive=True

Postgres_Connection.Value (Connection.new jdbc_connection Dialect.postgres Postgres_Type_Mapping entity_naming_properties data_link_setup) make_new
Postgres_Connection.Value (Connection.new jdbc_connection Dialect.postgres Postgres_Type_Mapping (Entity_Naming_Properties.from_jdbc_connection jdbc_connection encoding is_case_sensitive=True) data_link_setup) make_new

## ---
private: true
Expand All @@ -66,22 +64,22 @@ type Postgres_Connection
immediately instead of waiting for them to be automatically released.
The connection is not usable afterwards.
close : Nothing
close self = self.connection.close
close self = self.base_connection.close

## ---
icon: metadata
---
Returns the list of databases (or catalogs) for the connection.
databases : Vector Text
databases self =
self.connection.read_text_column "select datname from pg_database where datname not in ('template0', 'template1')" "datname"
self.base_connection.read_text_column "select datname from pg_database where datname not in ('template0', 'template1')" "datname"

## ---
icon: metadata
---
Returns the name of the current database (or catalog).
database : Text
database self = self.connection.database
database self = self.base_connection.database

## ---
icon: data_input
Expand All @@ -102,14 +100,14 @@ type Postgres_Connection
Returns the list of schemas for the connection within the current database
(or catalog).
schemas : Vector Text
schemas self = self.connection.schemas
schemas self = self.base_connection.schemas

## ---
icon: metadata
---
Returns the name of the current schema.
schema : Text
schema self = self.connection.schema
schema self = self.base_connection.schema

## ---
icon: data_input
Expand All @@ -130,7 +128,7 @@ type Postgres_Connection
---
Gets a list of the table types.
table_types : Vector Text
table_types self = self.connection.table_types
table_types self = self.base_connection.table_types

## ---
group: Standard.Base.Metadata
Expand Down Expand Up @@ -160,7 +158,7 @@ type Postgres_Connection
@schema (make_schema_selector include_any=True)
tables : Text -> Text -> Text -> Vector -> Boolean -> Table
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
self.base_connection.tables name_like database schema types all_fields

## ---
aliases: [import, load, open, read, sql]
Expand Down Expand Up @@ -210,7 +208,7 @@ type Postgres_Connection
@limit Rows_To_Read.default_widget
read : SQL_Query -> Rows_To_Read -> Table ! Table_Not_Found
read self query:SQL_Query (limit : Rows_To_Read = ..First_With_Warning 1000) =
self.connection.read query limit
self.base_connection.read query limit

## ---
group: Standard.Base.Output
Expand Down Expand Up @@ -297,7 +295,7 @@ type Postgres_Connection
@limit Rows_To_Read.default_widget
execute_query : Text | SQL_Statement -> Rows_To_Read -> Boolean -> Table
execute_query self query (limit : Rows_To_Read = ..First_With_Warning 1000) write_operation:Boolean=True =
self.connection.execute_query query limit write_operation
self.base_connection.execute_query query limit write_operation

## ---
advanced: true
Expand All @@ -314,7 +312,7 @@ type Postgres_Connection
representing the query to execute.
execute_update : Text | SQL_Statement -> Integer
execute_update self query =
self.connection.execute_update query
self.base_connection.execute_update query

## ---
private: true
Expand All @@ -331,31 +329,31 @@ type Postgres_Connection
representing the query to execute.
execute : Text | SQL_Statement -> Integer
execute self query =
self.connection.execute query
self.base_connection.execute query

## ---
private: true
---
Access the dialect.
dialect self = self.connection.dialect
dialect self = self.base_connection.dialect

## ---
private: true
---
Access the Type Mapping.
type_mapping self = self.connection.type_mapping
type_mapping self = self.base_connection.type_mapping

## ---
private: true
---
Access the Statement Setter.
statement_setter self = self.connection.statement_setter
statement_setter self = self.base_connection.statement_setter

## ---
private: true
---
Access the underlying JDBC connection.
jdbc_connection self = self.connection.jdbc_connection
jdbc_connection self = self.base_connection.jdbc_connection

## ---
private: true
Expand All @@ -368,7 +366,7 @@ type Postgres_Connection
does not exist. Defaults to `False`.
drop_table : Text -> Boolean -> Nothing
drop_table self table_name if_exists=False =
self.connection.drop_table table_name if_exists
self.base_connection.drop_table table_name if_exists

## ---
private: true
Expand All @@ -379,7 +377,7 @@ type Postgres_Connection
- `table_name`: the name of the table to truncate.
truncate_table : Text -> Nothing ! Table_Not_Found
truncate_table self table_name =
self.connection.truncate_table table_name
self.base_connection.truncate_table table_name

## ---
private: true
Expand Down Expand Up @@ -419,10 +417,10 @@ type Postgres_Connection
Converts this value to a JSON serializable object.
to_js_object : JS_Object
to_js_object self =
JS_Object.from_pairs <| [["type", "Postgres_Connection"], ["links", self.connection.tables.at "Name" . to_vector]]
JS_Object.from_pairs <| [["type", "Postgres_Connection"], ["links", self.tables.at "Name" . to_vector]]

## ---
private: true
---
Table_Viz_Data.from (that:Postgres_Connection) =
Connections_Helpers.get_table_viz_data (that.connection.tables.at "Name" . to_vector)
Connections_Helpers.get_table_viz_data (that.tables.at "Name" . to_vector)
Loading
Loading