1 Star 0 Fork 6

1701 / rust-rbatis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
dyn_sql.md 2.94 KB
一键复制 编辑 原始数据 按行查看 历史
zxj 提交于 2023-06-01 17:49 . rename to RBatis

RBatis Dynamic SQL

This library is a framework for generating dynamic SQL statements. Think of it as a typesafe SQL templating library, with additional support for RBatis and rbaits_sql.

The library will generate full DELETE, INSERT, SELECT, and UPDATE statements formatted for use by RBatis or any http library. The most common use case is to generate statements, and a matching set of parameters, that can be directly used by RBatis. The library will also generate statements and parameter objects that are compatible with rbaits_sql.

The library works by implementing an SQL-like DSL that creates an object containing a full SQL statement and any parameters required for that statement. The SQL statement object can be used directly by RBatis as a parameter to a mapper method.

The library will generate these types of SQL statements:

  • COUNT statements - specialized SELECT statements that return a i64/u64 value
  • DELETE statements with flexible WHERE clauses
  • INSERT statements of several types:
    • A statement that inserts a single row with values supplied from a corresponding Object
    • A statement that inserts a single row with values supplied directly in the statement
    • A statement that inserts multiple rows using multiple VALUES clauses
    • A statement that inserts multiple rows using a rbaits_sql batch
    • A statement that inserts into a table using the results of a SELECT statement
  • SELECT statements with a flexible column list, a flexible WHERE clause, and support for distinct, “group by”, joins, unions, “order by”, etc.
  • UPDATE statements with a flexible WHERE clause, and flexible SET clauses

The primary goals of the library are:

  1. Typesafe - to the extent possible, the library will ensure that parameter types match the database column types
  2. Expressive - statements are built in a way that clearly communicates their meaning (thanks to Hamcrest for some inspiration)
  3. Flexible - where clauses can be built using any combination of and, or, and nested conditions
  4. Extensible - the library will render statements for RBatis, rbaits_sql or plain sql. It can be extended to generate clauses for other frameworks as well. Custom where conditions can be added easily if none of the built in conditions are sufficient for your needs.
  5. Small - the library is a small dependency to add. It has no transitive dependencies.

This library is design for Zero cost Dynamic SQL, implemented using (proc-macro,compile-time,Cow(Reduce unnecessary cloning)) techniques。 Dynamic SQL is first compiled into RUST code, machine code which is eventually generated by the RUST compiler 。 don't need ONGL engine(mybatis)

doc link
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Rust
1
https://gitee.com/knowgo/rust-rbatis.git
git@gitee.com:knowgo/rust-rbatis.git
knowgo
rust-rbatis
rust-rbatis
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891