-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Create select_keys.rs * add select_keys
- Loading branch information
1 parent
0a030c2
commit c4510fb
Showing
5 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use super::select_keys_from::SelectKeysFrom; | ||
use crate::query::query_id::QueryId; | ||
use crate::query::query_ids::QueryIds; | ||
use crate::query::search_query::SearchQuery; | ||
use crate::query::select_keys_query::SelectKeysQuery; | ||
|
||
pub struct SelectKeys(pub SelectKeysQuery); | ||
|
||
impl SelectKeys { | ||
#[allow(clippy::wrong_self_convention)] | ||
pub fn from(mut self, id: QueryId) -> SelectKeysFrom { | ||
self.0 .0 = QueryIds::Id(id); | ||
|
||
SelectKeysFrom(self.0) | ||
} | ||
|
||
#[allow(clippy::wrong_self_convention)] | ||
pub fn from_ids(mut self, ids: &[QueryId]) -> SelectKeysFrom { | ||
self.0 .0 = QueryIds::Ids(ids.to_vec()); | ||
|
||
SelectKeysFrom(self.0) | ||
} | ||
|
||
#[allow(clippy::wrong_self_convention)] | ||
pub fn from_query(mut self, query: SearchQuery) -> SelectKeysFrom { | ||
self.0 .0 = QueryIds::Search(query); | ||
|
||
SelectKeysFrom(self.0) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
use crate::query::select_keys_query::SelectKeysQuery; | ||
|
||
pub struct SelectKeysFrom(pub SelectKeysQuery); | ||
|
||
impl SelectKeysFrom { | ||
pub fn query(self) -> SelectKeysQuery { | ||
self.0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
use agdb::QueryBuilder; | ||
|
||
#[test] | ||
fn select_keys_from() { | ||
let _query = QueryBuilder::select().keys().from("alias".into()).query(); | ||
} | ||
|
||
#[test] | ||
fn select_keys_from_ids() { | ||
let _query = QueryBuilder::select() | ||
.keys() | ||
.from_ids(&["alias".into()]) | ||
.query(); | ||
} | ||
|
||
#[test] | ||
fn select_keys_from_query() { | ||
let _query = QueryBuilder::select() | ||
.keys() | ||
.from_query(QueryBuilder::select().id().from("alias".into()).query()) | ||
.query(); | ||
} |