Skip to content

Commit

Permalink
refactor(code): remove "StructType::Form" (#72)
Browse files Browse the repository at this point in the history
because it is unused

fixes #70
  • Loading branch information
hasezoey authored Sep 4, 2023
1 parent 1937039 commit 4738d0f
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions src/code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ use crate::{GenerationConfig, TableOptions};
enum StructType {
/// Variant for the `Read` struct which can be queried and has all properties
Read,
// this struct type maps directly to a database row
Form, // this one contains primary key columns (not optional) and normal columns (optional) excluding those marked as autogenerated
/// Variant for a `Update*` struct, which has all properties wrapped in [`Option<>`]
Update,
/// Variant for a `Create` struct, which only has all the properties which are not autogenerated
Expand All @@ -23,7 +21,6 @@ impl StructType {
pub fn prefix(&self) -> &'static str {
match self {
StructType::Read => "",
StructType::Form => "",
StructType::Update => "Update",
StructType::Create => "Create",
}
Expand All @@ -35,7 +32,6 @@ impl StructType {
pub fn suffix(&self) -> &'static str {
match self {
StructType::Read => "",
StructType::Form => "Form",
StructType::Update => "",
StructType::Create => "",
}
Expand Down Expand Up @@ -169,7 +165,6 @@ impl<'a> Struct<'a> {

match self.ty {
StructType::Read => true,
StructType::Form => true,
StructType::Update => {
let is_pk = self.table.primary_key_columns.contains(&c.name);

Expand Down Expand Up @@ -207,7 +202,6 @@ impl<'a> Struct<'a> {

match self.ty {
StructType::Read => {}
StructType::Form => {}
StructType::Update => {
// all non-key fields should be optional in Form structs (to allow partial updates)
is_optional = !is_pk || (is_pk && is_autogenerated);
Expand Down

0 comments on commit 4738d0f

Please sign in to comment.