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

upgrade to sea-orm 0.12 and fix code #5

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ chrono = "0.4.26"
tera = "^1.19.0"
async-trait = "^0.1.68"
lazy_static = "^1.4.0"
itertools = "^0.10.5"
itertools = "^0.11.0"
serde = "^1.0.164"
serde_derive = "^1.0.164"
sea-orm = { version = "^0.11.3", features = [], default-features = false }
sea-orm = { version = "^0.12.2", features = [], default-features = false }
actix-admin-macros = { version = "0.5.0", path = "actix_admin_macros" }
derive_more = "0.99.17"
regex = "1.8.4"
urlencoding = "2.1.2"

[dev-dependencies]
sea-orm = { version = "^0.11.3", features = [ "sqlx-sqlite", "runtime-actix-native-tls", "macros" ], default-features = true }
sea-orm = { version = "^0.12.2", features = [ "sqlx-sqlite", "runtime-actix-native-tls", "macros" ], default-features = true }
actix-rt = "2.8.0"
azure_auth = { path = "./examples/azure_auth/azure_auth" }
oauth2 = "4.4.1"
dotenv = "0.15"
actix-session = { version = "0.7.2", features = ["cookie-session"] }
actix-session = { version = "0.7.2", features = ["cookie-session"] }
2 changes: 1 addition & 1 deletion actix_admin_macros/src/struct_fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub fn get_actix_admin_fields_searchable(fields: &Vec<ModelField>) -> Vec<TokenS
let column_name = capitalize_first_letter(&model_field.ident.to_string());
let column_ident = Ident::new(&column_name, Span::call_site());
quote! {
.add(Column::#column_ident.contains(&search))
.add(Column::#column_ident.contains(search))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was the main error;

Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
error: could not compile `actix-admin` (test "post_create_and_edit_is_success") due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error: could not compile `actix-admin` (test "delete_is_success") due to 4 previous errors
error: could not compile `actix-admin` (test "get_request_is_success") due to 4 previous errors
error[E0277]: the trait bound `std::string::String: std::convert::From<&&str>` is not satisfied
   --> examples/basic/entity/post.rs:9:123
    |
9   | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize, DeriveActixAdmin, DeriveActixAdminViewModel, DeriveActixAdminModel, DeriveActixAdminModelSelectList)]
    |                                                                                                                           ^^^^^^^^^^^^^^^^^^^^^ the trait `std::convert::From<&&str>` is not implemented for `std::string::String`
    |
    = note: required for `&&str` to implement `Into<std::string::String>`
note: required by a bound in `sea_orm::ColumnTrait::contains`
   --> /Users/keith/.asdf/installs/rust/1.71.1/registry/src/index.crates.io-6f17d22bba15001f/sea-orm-0.12.2/src/entity/column.rs:228:12
    |
226 |     fn contains<T>(&self, s: T) -> SimpleExpr
    |        -------- required by a bound in this associated function
227 |     where
228 |         T: Into<String>,
    |            ^^^^^^^^^^^^ required by this bound in `ColumnTrait::contains`
    = note: this error originates in the derive macro `DeriveActixAdminModel` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider dereferencing here
    |
9   | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize, DeriveActixAdmin, DeriveActixAdminViewModel, *DeriveActixAdminModel, DeriveActixAdminModelSelectList)]
    |

}
})
.collect::<Vec<_>>()
Expand Down
4 changes: 2 additions & 2 deletions examples/azure_auth/entity/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Related<super::comment::Entity> for Entity {

impl ActiveModelBehavior for ActiveModel {}

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveDisplay, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the main error was fixed I got errors about these.

error[E0599]: `Tea` doesn't implement `std::fmt::Display`
   --> tests/test_setup/post.rs:8:123
    |
8   | #[derive(Clone, Debug, PartialEq, DeriveEntityModel, Deserialize, Serialize, DeriveActixAdmin, DeriveActixAdminViewModel, DeriveActixAdminModel, DeriveActixAdminModelSelectList)]
    |                                                                                                                           ^^^^^^^^^^^^^^^^^^^^^ `Tea` cannot be formatted with the default formatter
...
51  | pub enum Tea {
    | ------------
    | |
    | method `to_string` not found for this enum
    | doesn't satisfy `Tea: ToString`
    | doesn't satisfy `Tea: std::fmt::Display`
    |
    = note: the following trait bounds were not satisfied:
            `Tea: std::fmt::Display`
            which is required by `Tea: ToString`
note: the trait `std::fmt::Display` must be implemented
   --> /Users/keith/.asdf/installs/rust/1.71.1/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:648:1
    |
648 | pub trait Display {
    | ^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `DeriveActixAdminModel` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: `Tea` doesn't implement `std::fmt::Display`
   --> tests/test_setup/post.rs:49:87
    |
49  | #[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
    |                                                                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Tea` cannot be formatted with the default formatter
50  | #[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")]
51  | pub enum Tea {
    | ------------
    | |
    | method `to_string` not found for this enum
    | doesn't satisfy `Tea: ToString`
    | doesn't satisfy `Tea: std::fmt::Display`
    |
    = note: the following trait bounds were not satisfied:
            `Tea: std::fmt::Display`
            which is required by `Tea: ToString`
note: the trait `std::fmt::Display` must be implemented
   --> /Users/keith/.asdf/installs/rust/1.71.1/toolchains/1.71.1-x86_64-apple-darwin/lib/rustlib/src/rust/library/core/src/fmt/mod.rs:648:1
    |
648 | pub trait Display {
    | ^^^^^^^^^^^^^^^^^
    = note: this error originates in the derive macro `DeriveActixAdminEnumSelectList` (in Nightly builds, run with -Z macro-backtrace for more info)

Which lead me to SeaQL/sea-orm#1726 where I saw that they pulled out the default Display impl.

#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")]
pub enum Tea {
#[sea_orm(string_value = "EverydayTea")]
Expand All @@ -69,4 +69,4 @@ impl FromStr for Tea {

impl ActixAdminModelValidationTrait<ActiveModel> for Entity {}

impl ActixAdminModelFilterTrait<Entity> for Entity {}
impl ActixAdminModelFilterTrait<Entity> for Entity {}
4 changes: 2 additions & 2 deletions examples/basic/entity/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl Related<super::comment::Entity> for Entity {

impl ActiveModelBehavior for ActiveModel {}

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveDisplay, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")]
pub enum Tea {
#[sea_orm(string_value = "EverydayTea")]
Expand All @@ -74,4 +74,4 @@ impl FromStr for Tea {

impl ActixAdminModelValidationTrait<ActiveModel> for Entity {}

impl ActixAdminModelFilterTrait<Entity> for Entity {}
impl ActixAdminModelFilterTrait<Entity> for Entity {}
2 changes: 1 addition & 1 deletion src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,4 +398,4 @@ impl ActixAdminBuilderTrait for ActixAdminBuilder {
fn get_actix_admin(&self) -> ActixAdmin {
self.actix_admin.clone()
}
}
}
4 changes: 2 additions & 2 deletions tests/test_setup/post.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl Related<super::comment::Entity> for Entity {

impl ActiveModelBehavior for ActiveModel {}

#[derive(Debug, Clone, PartialEq, EnumIter, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
#[derive(Debug, Clone, PartialEq, EnumIter, DeriveDisplay, DeriveActiveEnum, Deserialize, Serialize, DeriveActixAdminEnumSelectList)]
#[sea_orm(rs_type = "String", db_type = "Enum", enum_name = "tea")]
pub enum Tea {
#[sea_orm(string_value = "EverydayTea")]
Expand All @@ -69,4 +69,4 @@ impl FromStr for Tea {

impl ActixAdminModelValidationTrait<ActiveModel> for Entity {}

impl ActixAdminModelFilterTrait<Entity> for Entity {}
impl ActixAdminModelFilterTrait<Entity> for Entity {}