Skip to content

Commit e229264

Browse files
committed
feat: v0.5.1, solving clippy lintings and adapted the code to Rust v1.82.0
1 parent b855518 commit e229264

10 files changed

Lines changed: 93 additions & 59 deletions

File tree

Cargo.toml

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ members = [
2121

2222
[dependencies]
2323
# Project crates
24-
canyon_connection = { workspace = true, path = "canyon_connection" }
25-
canyon_crud = { workspace = true, path = "canyon_crud" }
26-
canyon_entities = { workspace = true, path = "canyon_entities" }
27-
canyon_migrations = { workspace = true, path = "canyon_migrations", optional = true }
28-
canyon_macros = { workspace = true, path = "canyon_macros" }
24+
canyon_connection = { workspace = true }
25+
canyon_crud = { workspace = true }
26+
canyon_entities = { workspace = true }
27+
canyon_migrations = { workspace = true, optional = true }
28+
canyon_macros = { workspace = true }
2929

3030
# To be marked as opt deps
3131
tokio-postgres = { workspace = true, optional = true }
@@ -35,11 +35,11 @@ mysql_common = { workspace = true, optional = true }
3535

3636

3737
[workspace.dependencies]
38-
canyon_crud = { version = "0.5.0", path = "canyon_crud" }
39-
canyon_connection = { version = "0.5.0", path = "canyon_connection" }
40-
canyon_entities = { version = "0.5.0", path = "canyon_entities" }
41-
canyon_migrations = { version = "0.5.0", path = "canyon_migrations"}
42-
canyon_macros = { version = "0.5.0", path = "canyon_macros" }
38+
canyon_crud = { version = "0.5.1", path = "canyon_crud" }
39+
canyon_connection = { version = "0.5.1", path = "canyon_connection" }
40+
canyon_entities = { version = "0.5.1", path = "canyon_entities" }
41+
canyon_migrations = { version = "0.5.1", path = "canyon_migrations"}
42+
canyon_macros = { version = "0.5.1", path = "canyon_macros" }
4343

4444
tokio = { version = "1.27.0", features = ["full"] }
4545
tokio-util = { version = "0.7.4", features = ["compat"] }
@@ -64,10 +64,8 @@ partialdebug = "0.2.0"
6464
quote = "1.0.9"
6565
proc-macro2 = "1.0.27"
6666

67-
68-
6967
[workspace.package]
70-
version = "0.5.0"
68+
version = "0.5.1"
7169
edition = "2021"
7270
authors = ["Alex Vergara<pyzyryab@tutanota.com>, Gonzalo Busto Musi<gonzalo.busto@gmail.com>"]
7371
documentation = "https://zerodaycode.github.io/canyon-book/"
@@ -77,7 +75,7 @@ license = "MIT"
7775
description = "A Rust ORM and QueryBuilder"
7876

7977
[features]
80-
postgres = ["tokio-postgres", "canyon_connection/postgres", "canyon_crud/postgres", "canyon_migrations/postgres", "canyon_macros/postgres"]
81-
mssql = ["tiberius", "canyon_connection/mssql", "canyon_crud/mssql", "canyon_migrations/mssql", "canyon_macros/mssql"]
82-
mysql = ["mysql_async", "mysql_common", "canyon_connection/mysql", "canyon_crud/mysql", "canyon_migrations/mysql", "canyon_macros/mysql"]
78+
postgres = ["tokio-postgres", "canyon_connection/postgres", "canyon_crud/postgres", "canyon_migrations/postgres", "canyon_macros/postgres"]
79+
mssql = ["tiberius", "canyon_connection/mssql", "canyon_crud/mssql", "canyon_migrations/mssql", "canyon_macros/mssql"]
80+
mysql = ["mysql_async", "mysql_common", "canyon_connection/mysql", "canyon_crud/mysql", "canyon_migrations/mysql", "canyon_macros/mysql"]
8381
migrations = ["canyon_migrations", "canyon_macros/migrations"]

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,40 @@ If you want to run the tests (because this is the first thing that you want to d
140140
- If you have Docker, and `Canyon-SQL` cloned of forked, you can run our docker-compose file `(docker/docker-compose.yml)`, which will initialize a `PostgreSQL` and `MySql` database and will put content on it to make the tests able to work.
141141
- Finally, some tests run against `MSSQL`. We didn't found a nice way of inserting data directly when the Docker wakes up, but instead, we run a very special test located at `tests/crud/mod.rs`, that is named `initialize_sql_server_docker_instance`. When you run this one, initial data will be inserted into the tables that are created when this test run.
142142
(If you know a better way of doing this, please, open an issue to let us know, and improve this process!)
143+
144+
## Known issues
145+
146+
### Missing dependency: OpenSSL
147+
148+
There's a certain set of common issues while building `Canyon-SQL` in development or in client code. Those building issues
149+
are related with missing packages or dependencies that `Cargo` doesn't resolves automatically depending on the underlying OS.
150+
151+
```
152+
openssl-sys@0.9.104: Could not find directory of OpenSSL installation, and this `-sys` crate cannot proceed without this knowledge.
153+
If OpenSSL is installed and this crate had trouble finding it, you can set the `OPENSSL_DIR` environment variable for the compilation process.
154+
See stderr section below for further information.
155+
```
156+
157+
This means that the `OpenSSL` package isn't installed on your system or not in *PATH*.
158+
159+
In a Debian based system, you can just `sudo apt install libssl-dev`. For others, just use your package manager
160+
to solve it by install it.
161+
162+
### Missing dependency: pkg-config
163+
164+
```
165+
Could not find openssl via pkg-config:
166+
Could not run `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags openssl`
167+
The pkg-config command could not be found.
168+
```
169+
`Cargo` may try to discover the `OpenSSL` package via `pkg-config`. If you find this error, you can
170+
`sudo apt install pkg-config` on *apt* based systems. For other systems, you must read your package manager
171+
docs and install it.
172+
173+
### failed to run custom build command for `libgssapi-sys vX.X.X`
174+
175+
The problem is missing a *C* header `gssapi.h`.
176+
177+
- Alpine: `apk --update add krb5-pkinit krb5-dev krb5`
178+
- Ubuntu: `apt-get -y install gcc libgssapi-krb5-2 libkrb5-dev libsasl2-modules-gssapi-mit`
179+

canyon_crud/src/query_elements/query_builder.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ pub mod ops {
6666
/// Generates a `WHERE` SQL clause for constraint the query.
6767
///
6868
/// * `column` - A [`FieldValueIdentifier`] that will provide the target
69-
/// column name and the value for the filter
69+
/// column name and the value for the filter
7070
/// * `op` - Any element that implements [`Operator`] for create the comparison
71-
/// or equality binary operator
71+
/// or equality binary operator
7272
fn r#where<Z: FieldValueIdentifier<'a, T>>(
7373
&mut self,
7474
column: Z,
@@ -80,9 +80,9 @@ pub mod ops {
8080
/// Generates an `AND` SQL clause for constraint the query.
8181
///
8282
/// * `column` - A [`FieldValueIdentifier`] that will provide the target
83-
/// column name and the value for the filter
83+
/// column name and the value for the filter
8484
/// * `op` - Any element that implements [`Operator`] for create the comparison
85-
/// or equality binary operator
85+
/// or equality binary operator
8686
fn and<Z: FieldValueIdentifier<'a, T>>(
8787
&mut self,
8888
column: Z,
@@ -93,10 +93,10 @@ pub mod ops {
9393
/// the filter in conjunction with an `IN` operator that will ac
9494
///
9595
/// * `column` - A [`FieldIdentifier`] that will provide the target
96-
/// column name for the filter, based on the variant that represents
97-
/// the field name that maps the targeted column name
96+
/// column name for the filter, based on the variant that represents
97+
/// the field name that maps the targeted column name
9898
/// * `values` - An array of [`QueryParameter`] with the values to filter
99-
/// inside the `IN` operator
99+
/// inside the `IN` operator
100100
fn and_values_in<Z, Q>(&mut self, column: Z, values: &'a [Q]) -> &mut Self
101101
where
102102
Z: FieldIdentifier<T>,
@@ -106,10 +106,10 @@ pub mod ops {
106106
/// the filter in conjunction with an `IN` operator that will ac
107107
///
108108
/// * `column` - A [`FieldIdentifier`] that will provide the target
109-
/// column name for the filter, based on the variant that represents
110-
/// the field name that maps the targeted column name
109+
/// column name for the filter, based on the variant that represents
110+
/// the field name that maps the targeted column name
111111
/// * `values` - An array of [`QueryParameter`] with the values to filter
112-
/// inside the `IN` operator
112+
/// inside the `IN` operator
113113
fn or_values_in<Z, Q>(&mut self, r#or: Z, values: &'a [Q]) -> &mut Self
114114
where
115115
Z: FieldIdentifier<T>,
@@ -118,18 +118,16 @@ pub mod ops {
118118
/// Generates an `OR` SQL clause for constraint the query.
119119
///
120120
/// * `column` - A [`FieldValueIdentifier`] that will provide the target
121-
/// column name and the value for the filter
121+
/// column name and the value for the filter
122122
/// * `op` - Any element that implements [`Operator`] for create the comparison
123-
/// or equality binary operator
123+
/// or equality binary operator
124124
fn or<Z: FieldValueIdentifier<'a, T>>(&mut self, column: Z, op: impl Operator)
125125
-> &mut Self;
126126

127127
/// Generates a `ORDER BY` SQL clause for constraint the query.
128128
///
129-
/// * `order_by` - A [`FieldIdentifier`] that will provide the target
130-
/// column name
131-
/// * `desc` - a boolean indicating if the generated `ORDER_BY` must be
132-
/// in ascending or descending order
129+
/// * `order_by` - A [`FieldIdentifier`] that will provide the target column name
130+
/// * `desc` - a boolean indicating if the generated `ORDER_BY` must be in ascending or descending order
133131
fn order_by<Z: FieldIdentifier<T>>(&mut self, order_by: Z, desc: bool) -> &mut Self;
134132
}
135133
}
@@ -452,9 +450,9 @@ where
452450
}
453451

454452
/// Contains the specific database operations of the *UPDATE* SQL statements.
455-
///
453+
///
456454
/// * `set` - To construct a new `SET` clause to determine the columns to
457-
/// update with the provided values
455+
/// update with the provided values
458456
#[derive(Debug, Clone)]
459457
pub struct UpdateQueryBuilder<'a, T>
460458
where
@@ -590,9 +588,9 @@ where
590588

591589
/// Contains the specific database operations associated with the
592590
/// *DELETE* SQL statements.
593-
///
591+
///
594592
/// * `set` - To construct a new `SET` clause to determine the columns to
595-
/// update with the provided values
593+
/// update with the provided values
596594
#[derive(Debug, Clone)]
597595
pub struct DeleteQueryBuilder<'a, T>
598596
where

canyon_macros/src/utils/function_parser.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use syn::{
55

66
/// Implementation of syn::Parse for the `#[canyon]` proc-macro
77
#[derive(Clone)]
8+
#[allow(dead_code)]
89
pub struct FunctionParser {
910
pub attrs: Vec<Attribute>,
1011
pub vis: Visibility,

canyon_macros/src/utils/helpers.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ fn test_entity_database_name_defaulter() {
127127
"MajorLeague".to_owned()
128128
);
129129
}
130-
///
130+
131+
/// Autogenerates a default table name for an entity given their struct name
131132
pub fn default_database_table_name_from_entity_name(ty: &str) -> String {
132133
let struct_name: String = ty.to_string();
133134
let mut table_name: String = String::new();

canyon_macros/src/utils/macro_tokens.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use syn::{Attribute, DeriveInput, Fields, Generics, Type, Visibility};
66

77
/// Provides a convenient way of store the data for the TokenStream
88
/// received on a macro
9+
#[allow(dead_code)]
910
pub struct MacroTokens<'a> {
1011
pub vis: &'a Visibility,
1112
pub ty: &'a Ident,
@@ -114,7 +115,7 @@ impl<'a> MacroTokens<'a> {
114115
column_names_as_chars.as_str().to_owned()
115116
}
116117

117-
///
118+
/// Retrieves the value of the index of an annotated field with #[primary_key]
118119
pub fn get_pk_index(&self) -> Option<usize> {
119120
let mut pk_index = None;
120121
for (idx, field) in self.fields.iter().enumerate() {

canyon_migrations/src/migrations/memory.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ impl Transaction<Self> for CanyonMemory {}
5757
impl CanyonMemory {
5858
/// Queries the database to retrieve internal data about the structures
5959
/// tracked by `CanyonSQL`
60-
#[cfg(not(cargo_check))]
6160
#[allow(clippy::nonminimal_bool)]
6261
pub async fn remember(
6362
datasource: &DatasourceConfig,
@@ -184,7 +183,6 @@ impl CanyonMemory {
184183

185184
/// Parses the Rust source code files to find the one who contains Canyon entities
186185
/// ie -> annotated with `#[canyon_entity]`
187-
#[cfg(not(cargo_check))]
188186
async fn find_canyon_entity_annotated_structs(
189187
&mut self,
190188
canyon_entities: &[CanyonRegisterEntity<'_>],

tests/canyon_integration_tests.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// Integration tests for the heart of a Canyon-SQL application, the CRUD operations.
1+
/// Integration tests for the heart of a Canyon-SQL application, the CRUD operations.
22
///
3-
// This tests will tests mostly the whole source code of Canyon, due to its integration nature
3+
/// This tests will tests mostly the whole source code of Canyon, due to its integration nature
44
///
5-
// Guide-style: Almost every operation in Canyon is `Result` wrapped (without the) unckecked
6-
// variants of the `find_all` implementations. We will go to directly `.unwrap()` the results
7-
// because, if there's something wrong in the code reported by the tests, we want to *panic*
8-
// and abort the execution.
5+
/// Guide-style: Almost every operation in Canyon is `Result` wrapped (without the) unckecked
6+
/// variants of the `find_all` implementations. We will go to directly `.unwrap()` the results
7+
/// because, if there's something wrong in the code reported by the tests, we want to *panic*
8+
/// and abort the execution.
99
extern crate canyon_sql;
1010

1111
use std::error::Error;

tests/crud/foreign_key_operations.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
// Integration tests for the CRUD operations available in `Canyon` that
2-
// generates and executes *SELECT* statements based on a entity
3-
// annotated with the `#[foreign_key(... args)]` annotation looking
4-
// for the related data with some entity `U` that acts as is parent, where `U`
5-
// impls `ForeignKeyable` (isn't required, but it won't unlock the
6-
// reverse search features parent -> child, only the child -> parent ones).
1+
/// Integration tests for the CRUD operations available in `Canyon` that
2+
/// generates and executes *SELECT* statements based on a entity
3+
/// annotated with the `#[foreign_key(... args)]` annotation looking
4+
/// for the related data with some entity `U` that acts as is parent, where `U`
5+
/// impls `ForeignKeyable` (isn't required, but it won't unlock the
6+
/// reverse search features parent -> child, only the child -> parent ones).
77
///
8-
// Names of the foreign key methods are autogenerated for the direct and
9-
// reverse side of the implementations.
10-
// For more info: TODO -> Link to the docs of the foreign key chapter
8+
/// Names of the foreign key methods are autogenerated for the direct and
9+
/// reverse side of the implementations.
10+
/// For more info: TODO -> Link to the docs of the foreign key chapter
1111
use canyon_sql::crud::CrudOperations;
1212

1313
#[cfg(feature = "mssql")]

tests/crud/querybuilder_operations.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use crate::constants::MYSQL_DS;
33
#[cfg(feature = "mssql")]
44
use crate::constants::SQL_SERVER_DS;
55

6-
// Tests for the QueryBuilder available operations within Canyon.
6+
/// Tests for the QueryBuilder available operations within Canyon.
77
///
8-
// QueryBuilder are the way of obtain more flexibility that with
9-
// the default generated queries, essentially for build the queries
10-
// with the SQL filters
8+
/// QueryBuilder are the way of obtain more flexibility that with
9+
/// the default generated queries, essentially for build the queries
10+
/// with the SQL filters
1111
///
1212
use canyon_sql::{
1313
crud::CrudOperations,

0 commit comments

Comments
 (0)