diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c643aa5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + push: + branches: ["main"] + pull_request: + +env: + MINIMUM_LINE_COVERAGE_PERCENT: 0 + +jobs: + fmt: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: rustup update && rustup component add rustfmt + - run: cargo fmt --check --all + + clippy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: rustup update && rustup component add clippy + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --workspace -- -D warnings -D clippy::all + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + lfs: "true" + - uses: isbang/compose-action@v1.5.1 + with: + compose-file: "./tests/postgres.yml" + - run: rustup update + - uses: Swatinem/rust-cache@v2 + - run: cargo test --workspace + env: + RUST_BACKTRACE: 1 + DATABASE_URL: postgres://atmosphere:atmosphere@localhost:5432 + + typos: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: Swatinem/rust-cache@v2 + - run: cargo install typos-cli || true + - run: typos diff --git a/README.md b/README.md index 3a4ccb5..728c1cf 100644 --- a/README.md +++ b/README.md @@ -183,7 +183,7 @@ Atmosphere is able to derive and generate the following queries: ### Field Queries -Each struct field that is marked with `#[sql(unique)]` becomes queriable. +Each struct field that is marked with `#[sql(unique)]` becomes queryable. In the above example `b` was marked as unique so atmosphere implements: diff --git a/atmosphere-core/src/rel.rs b/atmosphere-core/src/rel.rs index 01c9935..d445c85 100644 --- a/atmosphere-core/src/rel.rs +++ b/atmosphere-core/src/rel.rs @@ -56,7 +56,7 @@ where /// entities referring to `Self`, resolving by primary key, and deleting all such referring /// entities. #[async_trait] -pub trait ReferedBy +pub trait ReferredBy where Self: Table + Bind + Unpin + Sync, Other: Table + Bind + RefersTo + Unpin + Sync, diff --git a/atmosphere-macros/src/derive/relationships.rs b/atmosphere-macros/src/derive/relationships.rs index d71cab3..d973a89 100644 --- a/atmosphere-macros/src/derive/relationships.rs +++ b/atmosphere-macros/src/derive/relationships.rs @@ -57,7 +57,7 @@ pub fn relationships(table: &Table) -> TokenStream { E: ::sqlx::Executor<'e, Database = ::atmosphere::Driver>, for<'q> <::atmosphere::Driver as ::sqlx::database::HasArguments<'q>>::Arguments: ::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { - <#other as ::atmosphere::rel::ReferedBy<#ident>>::resolve_by(pk, executor).await + <#other as ::atmosphere::rel::ReferredBy<#ident>>::resolve_by(pk, executor).await } } @@ -71,7 +71,7 @@ pub fn relationships(table: &Table) -> TokenStream { E: ::sqlx::Executor<'e, Database = ::atmosphere::Driver>, for<'q> <::atmosphere::Driver as ::sqlx::database::HasArguments<'q>>::Arguments: ::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { - <#other as ::atmosphere::rel::ReferedBy<#ident>>::resolve(&self, executor).await + <#other as ::atmosphere::rel::ReferredBy<#ident>>::resolve(&self, executor).await } pub async fn #delete_self<'e, E>( @@ -82,7 +82,7 @@ pub fn relationships(table: &Table) -> TokenStream { E: ::sqlx::Executor<'e, Database = ::atmosphere::Driver>, for<'q> <::atmosphere::Driver as ::sqlx::database::HasArguments<'q>>::Arguments: ::sqlx::IntoArguments<'q, ::atmosphere::Driver> + Send { - <#other as ::atmosphere::rel::ReferedBy<#ident>>::delete_all(&self, executor).await + <#other as ::atmosphere::rel::ReferredBy<#ident>>::delete_all(&self, executor).await } } @@ -92,7 +92,7 @@ pub fn relationships(table: &Table) -> TokenStream { } #[automatically_derived] - impl ::atmosphere::rel::ReferedBy<#ident> for #other {} + impl ::atmosphere::rel::ReferredBy<#ident> for #other {} )); } diff --git a/atmosphere-macros/src/schema/relation.rs b/atmosphere-macros/src/schema/relation.rs index e69de29..8b13789 100644 --- a/atmosphere-macros/src/schema/relation.rs +++ b/atmosphere-macros/src/schema/relation.rs @@ -0,0 +1 @@ + diff --git a/atmosphere-macros/src/schema/table.rs b/atmosphere-macros/src/schema/table.rs index da224f3..c9980b7 100644 --- a/atmosphere-macros/src/schema/table.rs +++ b/atmosphere-macros/src/schema/table.rs @@ -42,7 +42,7 @@ impl Parse for TableId { } let schema = schema.ok_or_else(|| { - syn::Error::new(input.span(), "`#[table]` requies a value for `schema`") + syn::Error::new(input.span(), "`#[table]` requires a value for `schema`") })?; let table = table.ok_or_else(|| { diff --git a/tests/postgres.yml b/tests/postgres.yml new file mode 100644 index 0000000..e5272b3 --- /dev/null +++ b/tests/postgres.yml @@ -0,0 +1,9 @@ +version: "3.9" +services: + database: + image: postgres:16 + environment: + POSTGRES_PASSWORD: atmosphere + POSTGRES_USER: atmosphere + ports: + - 127.0.0.1:5432:5432