Compare commits

..

No commits in common. "8e9d2e06d4a6a9bf7aeee34f38e0ec619f36ea40" and "3b134cdb6ce2c036f1619599d86ccb2c7f28aef2" have entirely different histories.

13 changed files with 30 additions and 41 deletions

42
Cargo.lock generated
View file

@ -486,6 +486,25 @@ dependencies = [
"slab",
]
[[package]]
name = "generator_cli"
version = "0.0.0"
dependencies = [
"anyhow",
"argh",
"attribute-derive",
"convert_case",
"fully_pub",
"heck",
"prettyplease",
"proc-macro2",
"quote",
"serde",
"serde_json",
"structmeta",
"syn",
]
[[package]]
name = "generic-array"
version = "0.14.7"
@ -1184,7 +1203,7 @@ dependencies = [
"fully_pub",
"serde",
"sqlx",
"sqlxgentools_attrs",
"sqlx_tools_attributes",
]
[[package]]
@ -1522,32 +1541,13 @@ dependencies = [
]
[[package]]
name = "sqlxgentools_attrs"
name = "sqlx_tools_attributes"
version = "0.0.0"
dependencies = [
"attribute-derive",
"proc-macro2",
]
[[package]]
name = "sqlxgentools_cli"
version = "0.0.0"
dependencies = [
"anyhow",
"argh",
"attribute-derive",
"convert_case",
"fully_pub",
"heck",
"prettyplease",
"proc-macro2",
"quote",
"serde",
"serde_json",
"structmeta",
"syn",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"

View file

@ -1,8 +1,8 @@
[workspace]
resolver = "2"
members = [
"lib/sqlxgentools_attrs",
"lib/sqlxgentools_cli",
"lib/sqlx_tools_attributes",
"lib/sqlx_tools_generator_cli",
"lib/sandbox"
]

View file

@ -1,6 +1,8 @@
# [WIP] sqlxgentools
Tools to generate SQL migrations and Rust SQLx repositories code from models structs to use with a SQLite database.
better name: sqlitexgentools, sqlitexgen
Tools to generate SQL migrations and Rust SQLx repositories code from models structs in a SQLite context.
Will be used in [minauthator](https://forge.lefuturiste.fr/mbess/minauthator).
@ -18,18 +20,6 @@ Will be used in [minauthator](https://forge.lefuturiste.fr/mbess/minauthator).
- Provide a full a ORM interface
## Features
- [x] generate migrations
- [x] from scratch
- [ ] up migration
- [ ] down migration
- [x] generate repositories
- [x] get_all
- [x] get_by_id
- [x] insert
- [x] insert_many
## Usage
### Generate initial CREATE TABLE sqlite migration

View file

@ -11,4 +11,4 @@ chrono = "0.4.39"
fully_pub = "0.1.4"
serde = "1.0.216"
sqlx = { version = "0.8.2", features = ["chrono", "uuid", "sqlite"] }
sqlxgentools_attrs = { path = "../sqlxgentools_attrs" }
sqlx_tools_attributes = { path = "../sqlx_tools_attributes" }

View file

@ -2,7 +2,7 @@ use chrono::{DateTime, Utc};
use sqlx::types::Json;
use fully_pub::fully_pub;
use sqlxgentools_attrs::{sql_generator_model, SqlGeneratorDerive};
use sqlx_tools_attributes::{sql_generator_model, SqlGeneratorDerive};
#[derive(sqlx::Type, Clone, Debug, PartialEq)]
enum UserStatus {

View file

@ -1,5 +1,5 @@
[package]
name = "sqlxgentools_attrs"
name = "sqlx_tools_attributes"
edition = "2021"
[dependencies]

View file

@ -1,5 +1,5 @@
[package]
name = "sqlxgentools_cli"
name = "generator_cli"
edition = "2021"
[[bin]]

View file

@ -9,7 +9,6 @@ impl Field {
fn sql_type(&self) -> Option<String> {
// for now, we just match against the rust type string representation
match self.rust_type.as_str() {
"usize" => Some("INTEGER".into()),
"u64" => Some("INTEGER".into()),
"u32" => Some("INTEGER".into()),
"i32" => Some("INTEGER".into()),