-
Notifications
You must be signed in to change notification settings - Fork 13
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
base: master
Are you sure you want to change the base?
Conversation
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}"); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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
No description provided.