-
-
Notifications
You must be signed in to change notification settings - Fork 527
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[issues] fully qualified
IdenStatic::as_str()
(#1280)
- Loading branch information
Showing
6 changed files
with
70 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
[workspace] | ||
# A separate workspace | ||
|
||
[package] | ||
name = "sea-orm-issues-1278" | ||
version = "0.1.0" | ||
edition = "2021" | ||
publish = false | ||
|
||
[dependencies] | ||
serde = "^1" | ||
tokio = { version = "^1", features = ["rt", "rt-multi-thread", "macros"] } | ||
|
||
[dependencies.sea-orm] | ||
path = "../../" | ||
default-features = false | ||
features = ["macros", "runtime-tokio-native-tls"] |
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,14 @@ | ||
use sea_orm::entity::prelude::*; | ||
|
||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)] | ||
#[sea_orm(table_name = "pool")] | ||
pub struct Model { | ||
#[sea_orm(primary_key)] | ||
pub id: i32, | ||
pub name: String, | ||
} | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)] | ||
pub enum Relation {} | ||
|
||
impl ActiveModelBehavior for ActiveModel {} |
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,36 @@ | ||
use sea_orm::{ | ||
Database, DeriveColumn, EntityTrait, EnumIter, FromQueryResult, QuerySelect, | ||
}; | ||
|
||
mod entity; | ||
|
||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)] | ||
enum QueryAs { | ||
PoolName, | ||
} | ||
|
||
#[derive(Debug, FromQueryResult)] | ||
struct PoolResult { | ||
name: String, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let db = Database::connect("xxxx").await.unwrap(); | ||
|
||
let result1 = entity::Entity::find() | ||
.select_only() | ||
.column(entity::Column::Name) | ||
.into_model::<PoolResult>() | ||
.all(&db) | ||
.await | ||
.unwrap(); | ||
|
||
let result2: Vec<String> = entity::Entity::find() | ||
.select_only() | ||
.column_as(entity::Column::Name, QueryAs::PoolName) | ||
.into_values::<_, QueryAs>() | ||
.all(&db) | ||
.await | ||
.unwrap(); | ||
} |
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