{"record":{"id":"ba60043d8dcd1665","repo":"transact-rs/sqlx","slug":"unimplemented","errorCode":null,"errorMessage":"unimplemented!()","messagePattern":"unimplemented!\\(\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sqlx-core/src/connection.rs","lineNumber":253,"sourceCode":"    /// * Password\n    /// * Hostname\n    /// * Port\n    /// * Database name\n    /// * Unix socket or SQLite database file path\n    /// * SSL mode (if applicable)\n    /// * SSL CA certificate path\n    /// * SSL client certificate path\n    /// * SSL client key path\n    ///\n    /// Additional settings are driver-specific. Refer to the source of a given implementation\n    /// to see which options are preserved in the URL.\n    ///\n    /// ### Panics\n    /// This defaults to `unimplemented!()`.\n    ///\n    /// Individual drivers should override this to implement the intended behavior.\n    fn to_url_lossy(&self) -> Url {\n        unimplemented!()\n    }\n\n    /// Establish a new database connection with the options specified by `self`.\n    fn connect(&self) -> impl Future<Output = Result<Self::Connection, Error>> + Send + '_\n    where\n        Self::Connection: Sized;\n\n    /// Log executed statements with the specified `level`\n    fn log_statements(self, level: LevelFilter) -> Self;\n\n    /// Log executed statements with a duration above the specified `duration`\n    /// at the specified `level`.\n    fn log_slow_statements(self, level: LevelFilter, duration: Duration) -> Self;\n\n    /// Entirely disables statement logging (both slow and regular).\n    fn disable_statement_logging(self) -> Self {\n        self.log_statements(LevelFilter::Off)\n            .log_slow_statements(LevelFilter::Off, Duration::default())","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/transact-rs/sqlx/blob/03af8bcc5711a1935580a54bea249c219a0c217d/sqlx-core/src/connection.rs#L235-L271","documentation":"`Connection::to_url_lossy` is a required trait method with a default implementation that panics via `unimplemented!()`. The sqlx trait provides this default so drivers that have not yet implemented URL-lossy stringification fail loudly at runtime instead of returning wrong data. Any call to `to_url_lossy` on a driver that does not override it panics.","triggerScenarios":"Calling `to_url_lossy()` on a connection/options object whose driver type does not override the default `unimplemented!()` body, e.g. calling it on a generic `impl Connection` or on a driver that never implemented the method.","commonSituations":"Generic logging/diagnostic code that tries to render any connection as a URL; code written against an older sqlx driver version before the driver implemented `to_url_lossy`; third-party or custom driver implementations that skipped the override.","solutions":["Do not call `to_url_lossy()` generically; render connection info per concrete driver type instead","Update the driver crate (e.g. sqlx-postgres/sqlx-mysql) to a version that overrides `to_url_lossy`","If you maintain a custom driver, implement `to_url_lossy` by building a `Url` from your connection options"],"exampleFix":"// before\nlet url = conn.to_url_lossy(); // panics for drivers without an override\n// after\nlet url = match &opts {\n    AnyConnectOptions::Postgres(p) => p.to_url_lossy(),\n    AnyConnectOptions::MySql(m) => m.to_url_lossy(),\n    _ => Url::parse(\"db://<redacted>\").unwrap(),\n};","handlingStrategy":"fallback","validationCode":"fn supports_to_url_lossy<D: Connection>(_: &D) -> bool { /* check driver feature via docs/tests */ true }","typeGuard":"fn is_postgres(c: &AnyConnection) -> bool { matches!(c.kind, AnyConnectionKind::Postgres) }","tryCatchPattern":"// Rust panics cannot be caught without panic::catch_unwind\nlet url = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| conn.to_url_lossy()))\n    .unwrap_or_else(|_| Url::parse(\"db://unknown\").unwrap());","preventionTips":["Avoid calling default trait methods documented as unimplemented on generic connection types","Pin and update driver crates that implement to_url_lossy","Write a unit test exercising to_url_lossy for every driver you support"],"tags":["rust","sqlx","unimplemented","panic","driver-api"],"backgroundTag":"unimplemented-trait-method","analyzedSha":"03af8bcc5711a1935580a54bea249c219a0c217d","analyzedAt":"2026-09-03T15:01:28.752Z","contentChangedAt":"2026-09-03T15:01:28.752Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}