diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c91d8375a0..18f20fe3e2f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,9 +12,11 @@ methods.][10434] - [Renamed `Location.Start` to `Location.Left` and `Location.End` to `Location.Right`.][10445] +- [Renamed `Postgres_Details.Postgres` to `Postgres.Server`.][10466] [10434]: https://github.com/enso-org/enso/pull/10434 [10445]: https://github.com/enso-org/enso/pull/10445 +[10466]: https://github.com/enso-org/enso/pull/10466 # Enso 2024.2 diff --git a/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso b/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso index 4578d24d4bff..9c99532bc76a 100644 --- a/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso +++ b/distribution/lib/Standard/AWS/0.0.0-dev/src/Database/Redshift/Internal/Redshift_Dialect.enso @@ -74,12 +74,11 @@ type Redshift_Dialect wrap_identifier self identifier = Base_Generator.wrap_in_quotes identifier - ## PRIVATE - Generates a SQL expression for a table literal. - make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder - make_table_literal self vecs column_names as_name = - Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name - + ## PRIVATE + Generates a SQL expression for a table literal. + make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder + make_table_literal self vecs column_names as_name = + Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name ## PRIVATE Prepares an ordering descriptor. diff --git a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json/Extensions.enso b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json/Extensions.enso index edb0d267fa21..10fcedd9e1bc 100644 --- a/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json/Extensions.enso +++ b/distribution/lib/Standard/Base/0.0.0-dev/src/Data/Json/Extensions.enso @@ -2,7 +2,6 @@ import project.Any.Any import project.Data.Array.Array import project.Data.Array_Proxy.Array_Proxy import project.Data.Decimal.Decimal -import project.Data.Numeric.Math_Context.Math_Context import project.Data.Json.JS_Object import project.Data.Json.Json import project.Data.Locale.Locale @@ -10,12 +9,13 @@ import project.Data.Map.Map import project.Data.Numbers.Float import project.Data.Numbers.Integer import project.Data.Numbers.Number +import project.Data.Numeric.Math_Context.Math_Context import project.Data.Text.Text import project.Data.Text.Text_Sub_Range.Text_Sub_Range import project.Data.Vector.Vector import project.Error.Error -import project.Errors.Illegal_Argument.Illegal_Argument import project.Errors.Deprecated.Deprecated +import project.Errors.Illegal_Argument.Illegal_Argument import project.Meta import project.Nothing.Nothing import project.Warning.Warning diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Connection_Details.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Connection_Details.enso index 87e0a89e4648..f590b0293d7b 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Connection_Details.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Connection_Details.enso @@ -9,7 +9,7 @@ from project.Errors import SQL_Error ## Specifies the connection details for the database. This is an interface that is implemented by particular database types, like - `Postgres_Details`, `SQLite` etc. + `Postgres`, `SQLite` etc. type Connection_Details ## PRIVATE diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Data_Link/Postgres_Data_Link.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Data_Link/Postgres_Data_Link.enso index 8096a58eacfe..42e4b7f41a10 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Data_Link/Postgres_Data_Link.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Data_Link/Postgres_Data_Link.enso @@ -8,17 +8,17 @@ from Standard.Base.Enso_Cloud.Public_Utils import get_optional_field, get_requir import project.Connection.Connection_Options.Connection_Options import project.Connection.Credentials.Credentials -import project.Connection.Postgres_Details.Postgres_Details +import project.Connection.Postgres.Postgres ## PRIVATE type Postgres_Data_Link ## PRIVATE A data-link returning a connection to the specified database. - Connection details:Postgres_Details + Connection details:Postgres ## PRIVATE A data-link returning a query to a specific table within a database. - Table name:Text details:Postgres_Details + Table name:Text details:Postgres ## PRIVATE @@ -34,7 +34,7 @@ type Postgres_Data_Link password = get_required_field "password" credentials_json |> parse_secure_value Credentials.Username_And_Password username password - details = Postgres_Details.Postgres host=host port=port database=db_name schema=schema credentials=credentials + details = Postgres.Server host=host port=port database=db_name schema=schema credentials=credentials case get_optional_field "table" json expected_type=Text of Nothing -> Postgres_Data_Link.Connection details diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Postgres_Details.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Postgres.enso similarity index 91% rename from distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Postgres_Details.enso rename to distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Postgres.enso index 73b71d1e195d..9a58b5c73c30 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Postgres_Details.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Connection/Postgres.enso @@ -12,7 +12,7 @@ import project.Internal.Postgres.Postgres_Data_Link_Setup.Postgres_Data_Link_Set polyglot java import org.postgresql.Driver -type Postgres_Details +type Postgres ## Connect to a PostgreSQL database. Arguments: @@ -28,7 +28,7 @@ type Postgres_Details - use_ssl: Whether to use SSL (defaults to `SSL_Mode.Prefer`). - client_cert: The client certificate to use or `Nothing` if not needed. @credentials Credentials.default_widget - Postgres (host:Text=default_postgres_host) (port:Integer=default_postgres_port) (database:Text=default_postgres_database) (schema:Text="") (credentials:(Credentials|Nothing)=Nothing) (use_ssl:SSL_Mode=SSL_Mode.Prefer) (client_cert:(Client_Certificate|Nothing)=Nothing) + Server (host:Text=default_postgres_host) (port:Integer=default_postgres_port) (database:Text=default_postgres_database) (schema:Text="") (credentials:(Credentials|Nothing)=Nothing) (use_ssl:SSL_Mode=SSL_Mode.Prefer) (client_cert:(Client_Certificate|Nothing)=Nothing) ## PRIVATE Build the Connection resource. @@ -46,7 +46,7 @@ type Postgres_Details ## Cannot use default argument values as gets in an infinite loop if you do. make_new database schema = - Postgres_Details.Postgres self.host self.port (database.if_nothing self.database) (schema.if_nothing self.schema) self.credentials self.use_ssl self.client_cert . connect options allow_data_links + Postgres.Server self.host self.port (database.if_nothing self.database) (schema.if_nothing self.schema) self.credentials self.use_ssl self.client_cert . connect options allow_data_links Postgres_Connection.create self.jdbc_url properties make_new data_link_setup diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Data_Link_Setup.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Data_Link_Setup.enso index d0422e7db1ef..4d1f67183968 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Data_Link_Setup.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Data_Link_Setup.enso @@ -8,13 +8,13 @@ import Standard.Base.Runtime.Context from Standard.Base.Enso_Cloud.Data_Link_Helpers import data_link_extension, secure_value_to_json import project.Connection.Credentials.Credentials -import project.Connection.Postgres_Details.Postgres_Details +import project.Connection.Postgres.Postgres import project.Connection.SSL_Mode.SSL_Mode ## PRIVATE type Postgres_Data_Link_Setup ## PRIVATE - Available details:Postgres_Details + Available details:Postgres ## PRIVATE Unavailable cause:Text @@ -45,7 +45,7 @@ type Postgres_Data_Link_Setup Error.throw (Illegal_Argument.Error "Cannot save connection as Data Link: "+cause) ## PRIVATE -prepare_credentials data_link_location:Enso_File details:Postgres_Details -> JS_Object | Nothing = +prepare_credentials data_link_location:Enso_File details:Postgres -> JS_Object | Nothing = case details.credentials of Nothing -> Nothing credentials:Credentials -> diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso index 792e6cc9aea0..47e1b5a93d33 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/Postgres/Postgres_Dialect.enso @@ -85,11 +85,11 @@ type Postgres_Dialect wrap_identifier self identifier = Base_Generator.wrap_in_quotes identifier - ## PRIVATE - Generates a SQL expression for a table literal. - make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder - make_table_literal self vecs column_names as_name = - Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name + ## PRIVATE + Generates a SQL expression for a table literal. + make_table_literal : Vector (Vector Text) -> Vector Text -> Text -> SQL_Builder + make_table_literal self vecs column_names as_name = + Base_Generator.default_make_table_literal self.wrap_identifier vecs column_names as_name ## PRIVATE Prepares an ordering descriptor. diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso index 146a08bc5a57..4cca20c4df10 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Internal/SQLite/SQLite_Dialect.enso @@ -64,6 +64,8 @@ type SQLite_Dialect generate_sql self query = Base_Generator.generate_query self query . build + ## PRIVATE + Generates SQL to truncate a table. generate_truncate_table_sql : Text -> SQL_Builder generate_truncate_table_sql self table_name = Base_Generator.truncate_table_delete_from_style self table_name diff --git a/distribution/lib/Standard/Database/0.0.0-dev/src/Main.enso b/distribution/lib/Standard/Database/0.0.0-dev/src/Main.enso index d83211a988de..b4e987ae8c19 100644 --- a/distribution/lib/Standard/Database/0.0.0-dev/src/Main.enso +++ b/distribution/lib/Standard/Database/0.0.0-dev/src/Main.enso @@ -3,12 +3,11 @@ export project.Connection.Client_Certificate.Client_Certificate export project.Connection.Connection_Options.Connection_Options export project.Connection.Credentials.Credentials export project.Connection.Database -export project.Connection.Postgres_Details.Postgres_Details +export project.Connection.Postgres.Postgres export project.Connection.SQLite.SQLite export project.Connection.SQLite_Format.SQLite_Format export project.Connection.SSL_Mode.SSL_Mode export project.SQL_Query.SQL_Query export project.Update_Action.Update_Action -from project.Connection.Postgres_Details.Postgres_Details export Postgres from project.Extensions.Upload_Database_Table export all from project.Extensions.Upload_In_Memory_Table export all diff --git a/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Connection.enso b/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Connection.enso index 679a24402bb5..31e9ab484122 100644 --- a/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Connection.enso +++ b/distribution/lib/Standard/Snowflake/0.0.0-dev/src/Internal/Snowflake_Connection.enso @@ -41,7 +41,7 @@ type Snowflake_Connection ## PRIVATE - A Postgres database connection. + A Snowflake database connection. Arguments: - connection: the underlying connection. diff --git a/std-bits/database/src/main/java/org/enso/database/postgres/PostgresConnectionDetailsSPI.java b/std-bits/database/src/main/java/org/enso/database/postgres/PostgresConnectionDetailsSPI.java index 46f94a31c9fa..ee357856e205 100644 --- a/std-bits/database/src/main/java/org/enso/database/postgres/PostgresConnectionDetailsSPI.java +++ b/std-bits/database/src/main/java/org/enso/database/postgres/PostgresConnectionDetailsSPI.java @@ -6,17 +6,17 @@ public class PostgresConnectionDetailsSPI extends DatabaseConnectionDetailsSPI { @Override protected String getModuleName() { - return "Standard.Database.Connection.Postgres_Details"; + return "Standard.Database.Connection.Postgres"; } @Override protected String getTypeName() { - return "Postgres_Details"; + return "Postgres"; } @Override protected String getCodeForDefaultConstructor() { - return "(Postgres 'localhost' 5432)"; + return "(Postgres.Server 'localhost' 5432)"; } @Override diff --git a/test/Table_Tests/src/Database/Postgres_Spec.enso b/test/Table_Tests/src/Database/Postgres_Spec.enso index 05206c460b7d..84356596f1ec 100644 --- a/test/Table_Tests/src/Database/Postgres_Spec.enso +++ b/test/Table_Tests/src/Database/Postgres_Spec.enso @@ -728,27 +728,27 @@ add_table_specs suite_builder = suite_builder.group "[PostgreSQL] SSL connectivity tests" pending=ssl_pending group_builder-> group_builder.specify "should connect without ssl parameter" <| - Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)) . should_succeed + Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password)) . should_succeed group_builder.specify "should connect, requiring SSL" <| - Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Require) . should_succeed + Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Require) . should_succeed group_builder.specify "should connect be able to verify the certificate" <| - Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Verify_CA ca_cert_file)) . should_succeed + Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Verify_CA ca_cert_file)) . should_succeed ## Default certificate should not accept the self signed certificate. - ca_fail = Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Verify_CA) + ca_fail = Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=SSL_Mode.Verify_CA) ca_fail.is_error . should_equal True ca_fail.catch SQL_Error . is_a SQL_Error . should_equal True group_builder.specify "should connect be able to verify the host name against the certificate" <| - Database.connect (Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) . should_succeed + Database.connect (Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) . should_succeed alternate_host = Environment.get "ENSO_POSTGRES_ALTERNATE_HOST" . if_nothing <| if db_host == "127.0.0.1" then "localhost" else Nothing pending_alternate = if alternate_host.is_nothing then "Alternative host name not configured." else Nothing group_builder.specify "should fail to connect with alternate host name not valid in certificate" pending=pending_alternate <| - ca_fail = Database.connect (Postgres alternate_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) + ca_fail = Database.connect (Postgres.Server alternate_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) use_ssl=(SSL_Mode.Full_Verification ca_cert_file)) ca_fail.is_error . should_equal True ca_fail.catch SQL_Error . is_a SQL_Error . should_equal True @@ -770,7 +770,7 @@ add_table_specs suite_builder = with_secret "my_postgres_username" db_user username_secret-> with_secret "my_postgres_password" db_password password_secret-> my_secret_name = "Enso Test: My Secret App NAME " + (Random.uuid.take 5) with_secret "my_postgres_app_name" my_secret_name app_name_secret-> Test.with_retries <| - details = Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password username_secret password_secret) + details = Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password username_secret password_secret) # We set the ApplicationName option, so that we can see that secrets can be used in custom properties. options = Connection_Options.Value [["ApplicationName", app_name_secret]] connection = Database.connect details options @@ -794,7 +794,7 @@ get_configured_connection_details = db_user = Environment.get "ENSO_POSTGRES_USER" db_password = Environment.get "ENSO_POSTGRES_PASSWORD" if db_name.is_nothing then Nothing else - Postgres db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) + Postgres.Server db_host db_port db_name credentials=(Credentials.Username_And_Password db_user db_password) ## Returns a function that takes anything and returns a new connection. The function creates a _new_ connection on each invocation @@ -852,12 +852,12 @@ add_pgpass_specs suite_builder = suite_builder.group "[PostgreSQL] .pgpass" grou add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Connection setup" group_builder-> group_builder.specify "should use environment variables as host, port and database defaults and fall back to hardcoded defaults" <| - c1 = Postgres "example.com" 12345 "my_db" - c2 = Postgres + c1 = Postgres.Server "example.com" 12345 "my_db" + c2 = Postgres.Server c3 = Test_Environment.unsafe_with_environment_override "PGHOST" "192.168.0.1" <| Test_Environment.unsafe_with_environment_override "PGPORT" "1000" <| Test_Environment.unsafe_with_environment_override "PGDATABASE" "ensoDB" <| - Postgres + Postgres.Server c1.host . should_equal "example.com" c1.port . should_equal 12345 @@ -877,7 +877,7 @@ add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Con ## Currently we require the port to be numeric. When we support Unix-sockets, we may lift that restriction. c4 = Test_Environment.unsafe_with_environment_override "PGPORT" "foobar" <| - Postgres + Postgres.Server c4.host . should_equal "localhost" c4.port . should_equal 5432 c4.database . should_equal "postgres" @@ -885,12 +885,12 @@ add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Con add_ssl props = props+[Pair.new 'sslmode' 'prefer'] group_builder.specify "should use the given credentials" <| - c = Postgres credentials=(Credentials.Username_And_Password "myuser" "mypass") + c = Postgres.Server credentials=(Credentials.Username_And_Password "myuser" "mypass") c.jdbc_url . should_equal "jdbc:postgresql://localhost:5432/postgres" c.jdbc_properties . should_equal <| add_ssl [Pair.new "user" "myuser", Pair.new "password" "mypass"] group_builder.specify "should fallback to environment variables and fill-out missing information based on the PGPASS file (if available)" <| - c1 = Postgres + c1 = Postgres.Server c1.jdbc_url . should_equal "jdbc:postgresql://localhost:5432/postgres" c1.jdbc_properties . should_equal <| add_ssl [] @@ -901,9 +901,9 @@ add_connection_setup_specs suite_builder = suite_builder.group "[PostgreSQL] Con Test_Environment.unsafe_with_environment_override "PGUSER" "someuser" <| c1.jdbc_properties . should_equal <| add_ssl [Pair.new "user" "someuser", Pair.new "password" "somepassword"] - c2 = Postgres "192.168.4.0" 1234 "foo" - c3 = Postgres "::1" 55999 "database_name" - c4 = Postgres "::1" 55999 "otherDB" + c2 = Postgres.Server "192.168.4.0" 1234 "foo" + c3 = Postgres.Server "::1" 55999 "database_name" + c4 = Postgres.Server "::1" 55999 "otherDB" c2.jdbc_properties . should_equal <| add_ssl [] c3.jdbc_properties . should_equal <| add_ssl [] c4.jdbc_properties . should_equal <| add_ssl []