Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Put reused filenames in constants #194

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jayvdb
Copy link
Collaborator

@jayvdb jayvdb commented Feb 28, 2024

No description provided.

use butane::db::{Connection, ConnectionSpec};
use butane::prelude::*;
use models::{Blog, Post};

/// Load a [Connection].
pub fn establish_connection() -> Connection {
butane::db::connect(&ConnectionSpec::load(".butane/connection.json").unwrap()).unwrap()
let connspec = format!("{BUTANE_DIRNAME}/{CONNECTION_JSON_FILENAME}");
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the fact that the examples need to include these strings feels like a problem.
These shouldnt need to be so visible - they should be a hidden detail that are only important for unusual usage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think ConnectionSpec::load should auto detect if this filename exists

@@ -29,6 +29,15 @@ use db::{BackendRow, Column, ConnectionMethods};
pub use query::Query;
pub use sqlval::{AsPrimaryKey, FieldType, FromSql, PrimaryKeyType, SqlVal, SqlValRef, ToSql};

/// Filenames used in butane.
pub mod _filenames {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using _ to indicate semi-private nature

@jayvdb jayvdb changed the title Put reused filenames in constants. Put reused filenames in constants Feb 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant