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

Introduce dynamic query/schema builder factory method #362

Closed
wants to merge 6 commits into from

Conversation

nitnelave
Copy link
Contributor

PR Info

Follow-up of #275 to clean up the interface, using launchbadge/sqlx#1228.

Adds

  • sea_query_binder::query_builder_from_kind to get a query builder from a dynamic SQLX DB connection.
  • sea_query_binder::schema_builder_from_kind same for schema.

Breaking Changes

  • Bumps a couple of dependencies.

let connection = AnyPool::connect(url).await.unwrap();
let mut pool = connection.try_acquire().unwrap();
let box_query_builder = query_builder_from_kind(pool.kind());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The interesting scenario here is to read the DB address from command-line, env or a config file, and as long as it's valid (connection was successful), build a query builder from whatever it resolved to.

Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

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

@nitnelave thank you for PR, some comments

Cargo.toml Show resolved Hide resolved
sea-query-binder/Cargo.toml Show resolved Hide resolved
Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

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

LGTM!

@tyt2y3 tyt2y3 changed the base branch from master to 0.25.x July 1, 2022 12:30
@tyt2y3
Copy link
Member

tyt2y3 commented Jul 1, 2022

Since the PR targets sqlx 0.5 (which you are still using) I can only merge that into 0.25.x. master now only targets sqlx 0.6. Would appreciate that you open a PR on that when you upgraded.

@nitnelave nitnelave closed this Jul 1, 2022
@nitnelave nitnelave deleted the builder_from branch July 1, 2022 12:44
@nitnelave
Copy link
Contributor Author

nitnelave commented Jul 1, 2022 via email

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.

3 participants