• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / pg_replicate / 15162015069

21 May 2025 12:20PM UTC coverage: 53.936% (+13.9%) from 40.016%
15162015069

push

github

web-flow
Merge pull request #121 from supabase/riccardo/feat/add-integration-test

318 of 422 new or added lines in 14 files covered. (75.36%)

2 existing lines in 2 files now uncovered.

3494 of 6478 relevant lines covered (53.94%)

26.11 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.5
/postgres/src/sqlx/options.rs
1
use secrecy::{ExposeSecret, Secret};
2
use serde::Deserialize;
3
use sqlx::postgres::{PgConnectOptions, PgSslMode};
4

5
/// Connection options for a PostgreSQL database.
6
///
7
/// Contains the connection parameters needed to establish a connection to a PostgreSQL
8
/// database server, including network location, authentication credentials, and security
9
/// settings.
10
#[derive(Debug, Clone, Deserialize)]
11
pub struct PgDatabaseOptions {
12
    /// Host name or IP address of the PostgreSQL server
13
    pub host: String,
14
    /// Port number that the PostgreSQL server listens on
15
    pub port: u16,
16
    /// Name of the target database
17
    pub name: String,
18
    /// Username for authentication
19
    pub username: String,
20
    /// Optional password for authentication, wrapped in [`Secret`] for secure handling
21
    pub password: Option<Secret<String>>,
22
    /// If true, requires SSL/TLS encryption for the connection
23
    pub require_ssl: bool,
24
}
25

26
impl PgDatabaseOptions {
27
    /// Creates connection options for connecting to the PostgreSQL server without
28
    /// specifying a database.
29
    ///
30
    /// Returns [`PgConnectOptions`] configured with the host, port, username, SSL mode
31
    /// and optional password from this instance. Useful for administrative operations
32
    /// that must be performed before connecting to a specific database, like database
33
    /// creation.
34
    pub fn without_db(&self) -> PgConnectOptions {
168✔
35
        let ssl_mode = if self.require_ssl {
168✔
NEW
36
            PgSslMode::Require
×
37
        } else {
38
            PgSslMode::Prefer
168✔
39
        };
40

41
        let options = PgConnectOptions::new_without_pgpass()
168✔
42
            .host(&self.host)
168✔
43
            .username(&self.username)
168✔
44
            .port(self.port)
168✔
45
            .ssl_mode(ssl_mode);
168✔
46

47
        if let Some(password) = &self.password {
168✔
48
            options.password(password.expose_secret())
168✔
49
        } else {
NEW
50
            options
×
51
        }
52
    }
168✔
53

54
    /// Creates connection options for connecting to a specific database.
55
    ///
56
    /// Returns [`PgConnectOptions`] configured with all connection parameters including
57
    /// the database name from this instance.
58
    pub fn with_db(&self) -> PgConnectOptions {
56✔
59
        self.without_db().database(&self.name)
56✔
60
    }
56✔
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc