首页 文章 精选 留言 我的

精选列表

搜索[rust],共2693篇文章
优秀的个人博客,低调大师

Diesel 2.1.0 发布,Rust ORM 框架

Diesel 2.1.0 已正式发布,此版本开发周期总共 9 个月,42 名贡献者提交了超过 380 个 commit。 Diesel 是一个安全可扩展的RustORM 框架和查询构建工具。Diesel 可避免运行时错误,提供最好的性能。 2.1.0 引入了多项新特性,并改进了现有功能。它引入了对通过 Diesel CLI 根据schema.rs文件和数据库之间的差异生成迁移的支持信息。 Diesel derived 现在提供了一个#[derive(MultiConnection)]derive 宏,允许轻松地将不同的数据库连接组合成一个单独的枚举,可自己实现Connection。 MySQL 后端通过ON DUPLICATE KEYS语法获得对upsert查询的支持。 此外还提供了新工具来改进为常见错误情况生成的复杂错误消息。详情查看 Changelog。 2.x 系列重写了大部分内部结构。因此这是新的大版本,它还包含许多破坏兼容性的变化,具体处理方案查看迁移指南。 更新亮点 支持MultiConnection Diesel 现在包含一个#[derive(MultiConnection)]proc 宏派生,它允许在单个应用程序中轻松支持多个数据库后端。它可以应用于不同连接的枚举: #[derive(diesel::MultiConnection)] pub enum AnyConnection { Postgresql(diesel::PgConnection), Mysql(diesel::MysqlConnection), Sqlite(diesel::SqliteConnection), } 之后AnyConnection类型可以用作普通连接: fn use_multi(conn: &mut AnyConnection) -> QueryResult<()> { // Use the connection enum as any other connection type // for inserting/updating/loading/… diesel::insert_into(users::table) .values(users::name.eq("Sean")) .execute(conn)?; let users = users::table.load::<(i32, String)>(conn)?; Ok(()) } 对 MySQL 后端的 Upsert 支持 Diesel 2.1 使用现有的upsert框架添加了对MySQL 后端INSERT INTO … ON DUPLICATE KEYS …查询的支持。现在支持使用 diesel 提供的 DSL 编写此类查询: diesel::insert_into(users) .values(&user2) .on_conflict(diesel::dsl::DuplicatedKeys) .do_update() .set(name.eq("I DONT KNOW ANYMORE")) .execute(conn)?; 改进错误信息 此版本改进了 rustc 为常见的 Diesel 问题生成的错误消息。 比如下面的示例: table! { users { id -> Integer, name -> Text, } } #[derive(Queryable)] struct User { name: String, id: i32, } users::table.load::<User>(&mut conn) 将生成以下错误消息: error[E0277]: the trait bound `(diesel::sql_types::Integer, diesel::sql_types::Text): load_dsl::private::CompatibleType<User, Mysql>` is not satisfied --> src/main.rs:20:31 | 20 | users::table.load::<User>(&mut conn); | ---- ^^^^^^^^^ the trait `load_dsl::private::CompatibleType<User, Mysql>` is not implemented for `(diesel::sql_types::Integer, diesel::sql_types::Text)` | | | required by a bound introduced by this call | = help: the following other types implement trait `load_dsl::private::CompatibleType<U, DB>`: (ST0, ST1) (ST0, ST1, ST2) (ST0, ST1, ST2, ST3) (ST0, ST1, ST2, ST3, ST4) (ST0, ST1, ST2, ST3, ST4, ST5) (ST0, ST1, ST2, ST3, ST4, ST5, ST6) (ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7) (ST0, ST1, ST2, ST3, ST4, ST5, ST6, ST7, ST8) and 24 others = note: required for `users::table` to implement `LoadQuery<'_, _, User>` note: required by a bound in `diesel::RunQueryDsl::load` --> /home/weiznich/.cargo/git/checkouts/diesel-6e3331fb3b9331ec/ef6252e/diesel/src/query_dsl/mod.rs:1543:15 | 1543 | Self: LoadQuery<'query, Conn, U>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `diesel::RunQueryDsl::load` 在新版本则生成以下错误信息: error[E0277]: the trait bound `i32: FromSql<diesel::sql_types::Text, Mysql>` is not satisfied --> src/main.rs:13:11 | 13 | name: i32, | ^^^ the trait `FromSql<diesel::sql_types::Text, Mysql>` is not implemented for `i32` | = help: the trait `FromSql<diesel::sql_types::Integer, Mysql>` is implemented for `i32` = note: required for `i32` to implement `diesel::Queryable<diesel::sql_types::Text, Mysql>` = note: required for `i32` to implement `FromSqlRow<diesel::sql_types::Text, Mysql>` = help: see issue #48214 Release Notes

资源下载

更多资源
Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册