From 049f500bde9a42943dbf34359eca4950cb263a7d Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Fri, 10 Jan 2025 16:29:26 +0200 Subject: [PATCH 01/26] Add support for additional model field types and arrays --- Cargo.toml | 3 +- loco-gen/Cargo.toml | 1 + loco-gen/src/lib.rs | 7 -- loco-gen/src/mappings.json | 206 ++++++++++++++++++++++++++++--------- loco-gen/src/model.rs | 136 +++++++++++++++++++++++- src/schema.rs | 113 +++++++++++++++++++- 6 files changed, 407 insertions(+), 59 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c264918cf..c512aaf98 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ fs-err = "2.11.0" # mailer tera = "1.19.1" thousands = "0.2.0" -heck = "0.4.0" +heck = { workspace = true } cruet = "0.13.0" lettre = { version = "0.11.4", default-features = false, features = [ "builder", @@ -179,6 +179,7 @@ tower-http = { version = "0.6.1", features = [ "set-header", "compression-full", ] } +heck = "0.4.0" [dependencies.sea-orm-migration] optional = true diff --git a/loco-gen/Cargo.toml b/loco-gen/Cargo.toml index a0d83fbeb..424ea6a0a 100644 --- a/loco-gen/Cargo.toml +++ b/loco-gen/Cargo.toml @@ -23,6 +23,7 @@ regex = { workspace = true } tracing = { workspace = true } chrono = { workspace = true } colored = { workspace = true } +heck = { workspace = true } clap = { version = "4.4.7", features = ["derive"] } duct = "0.13" diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index fc26b8f67..dcb8463ea 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -107,13 +107,6 @@ impl Mappings { .map(|f| &f.name) .collect::>() } - pub fn rust_fields(&self) -> Vec<&String> { - self.field_types - .iter() - .filter(|f| f.rust.is_some()) - .map(|f| &f.name) - .collect::>() - } } static MAPPINGS: OnceLock = OnceLock::new(); diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index 9b1418555..88b7c4a08 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -2,219 +2,248 @@ "field_types": [ { "name": "uuid", - "rust": "Uuid", "schema": "uuid_uniq", "col_type": "UuidUniq" }, { "name": "uuid_col", - "rust": "Option", "schema": "uuid_null", "col_type": "UuidNull" }, { "name": "uuid_col!", - "rust": "Uuid", "schema": "uuid", "col_type": "Uuid" }, { "name": "string", - "rust": "Option", "schema": "string_null", "col_type": "StringNull" }, { "name": "string!", - "rust": "String", "schema": "string", "col_type": "String" }, { "name": "string^", - "rust": "String", "schema": "string_uniq", "col_type": "StringUniq" }, { "name": "text", - "rust": "Option", "schema": "text_null", "col_type": "TextNull" }, { "name": "text!", - "rust": "String", "schema": "text", "col_type": "Text" }, + { + "name": "tiny_unsigned", + "schema": "tiny_unsigned_null", + "col_type": "TinyUnsignedNull" + }, + { + "name": "tiny_unsigned!", + "schema": "tiny_unsigned", + "col_type": "TinyUnsigned" + }, + { + "name": "tiny_unsigned^", + "schema": "tiny_unsigned_uniq", + "col_type": "TinyUnsignedUniq" + }, + { + "name": "small_unsigned", + "schema": "small_unsigned_null", + "col_type": "SmallUnsignedNull" + }, + { + "name": "small_unsigned!", + "schema": "small_unsigned", + "col_type": "SmallUnsigned" + }, + { + "name": "small_unsigned^", + "schema": "small_unsigned_uniq", + "col_type": "SmallUnsignedUniq" + }, + { + "name": "big_unsigned", + "schema": "big_unsigned_null", + "col_type": "BigUnsignedNull" + }, + { + "name": "big_unsigned!", + "schema": "big_unsigned", + "col_type": "BigUnsigned" + }, + { + "name": "big_unsigned^", + "schema": "big_unsigned_uniq", + "col_type": "BigUnsignedUniq" + }, { "name": "tiny_int", - "rust": "Option", "schema": "tiny_integer_null", "col_type": "TinyIntegerNull" }, { "name": "tiny_int!", - "rust": "i16", "schema": "tiny_integer", "col_type": "TinyInteger" }, { "name": "tiny_int^", - "rust": "i16", "schema": "tiny_integer_uniq", "col_type": "TinyIntegerUniq" }, { "name": "small_int", - "rust": "Option", "schema": "small_integer_null", "col_type": "SmallIntegerNull" }, { "name": "small_int!", - "rust": "i16", "schema": "small_integer", "col_type": "SmallInteger" }, { "name": "small_int^", - "rust": "i16", "schema": "small_integer_uniq", "col_type": "SmallIntegerUniq" }, { "name": "int", - "rust": "Option", "schema": "integer_null", "col_type": "IntegerNull" }, { "name": "int!", - "rust": "i32", "schema": "integer", "col_type": "Integer" }, { "name": "int^", - "rust": "i32", "schema": "integer_uniq", "col_type": "IntegerUniq" }, { "name": "big_int", - "rust": "Option", "schema": "big_integer_null", "col_type": "BigIntegerNull" }, { "name": "big_int!", - "rust": "i64", "schema": "big_integer", "col_type": "BigInteger" }, { "name": "big_int^", - "rust": "i64", "schema": "big_integer_uniq", "col_type": "BigIntegerUniq" }, { "name": "float", - "rust": "Option", "schema": "float_null", "col_type": "FloatNull" }, { "name": "float!", - "rust": "f32", "schema": "float", "col_type": "Float" }, { "name": "double", - "rust": "Option", "schema": "double_null", "col_type": "DoubleNull" }, { "name": "double!", - "rust": "f64", "schema": "double", "col_type": "Double" }, { "name": "decimal", - "rust": "Option", "schema": "decimal_null", "col_type": "DecimalNull" }, { "name": "decimal!", - "rust": "Decimal", "schema": "decimal", "col_type": "Decimal" }, { "name": "decimal_len", - "rust": "Option", "schema": "decimal_len_null", "col_type": "DecimalLenNull", - "arity":2 + "arity": 2 }, { "name": "decimal_len!", - "rust": "Decimal", "schema": "decimal_len", "col_type": "DecimalLen", - "arity":2 + "arity": 2 }, { "name": "bool", - "rust": "Option", "schema": "boolean_null", "col_type": "BooleanNull" }, { "name": "bool!", - "rust": "bool", "schema": "boolean", "col_type": "Boolean" }, { "name": "tstz", - "rust": "Option", "schema": "timestamp_with_time_zone_null", "col_type": "TimestampWithTimeZoneNull" }, { "name": "tstz!", - "rust": "DateTimeWithTimeZone", "schema": "timestamp_with_time_zone", "col_type": "TimestampWithTimeZone" }, { "name": "date", - "rust": "Option", "schema": "date_null", "col_type": "DateNull" }, { "name": "date!", - "rust": "Date", "schema": "date", "col_type": "Date" }, + { + "name": "date^", + "schema": "date_uniq", + "col_type": "DateUniq" + }, + { + "name": "date_time", + "schema": "date_time_null", + "col_type": "DateTimeNull" + }, + { + "name": "date_time!", + "schema": "date_time", + "col_type": "DateTime" + }, + { + "name": "date_time^", + "schema": "date_time_uniq", + "col_type": "DateTimeUniq" + }, { "name": "ts", - "rust": "Option", "schema": "timestamp_null", "col_type": "TimestampNull" }, { "name": "ts!", - "rust": "DateTime", "schema": "timestamp", "col_type": "Timestamp" }, @@ -226,45 +255,130 @@ }, { "name": "json!", - "rust": "serde_json::Value", "schema": "json", "col_type": "Json" }, { "name": "jsonb", - "rust": "Option", "schema": "json_binary_null", "col_type": "JsonBinaryNull" }, { "name": "jsonb!", - "rust": "serde_json::Value", "schema": "json_binary", "col_type": "JsonBinary" }, { "name": "blob", - "rust": "Option>", "schema": "blob_null", "col_type": "BlobNull" }, { "name": "blob!", - "rust": "Vec", "schema": "blob", "col_type": "Blob" }, { "name": "money", - "rust": "Option", "schema": "money_null", "col_type": "MoneyNull" }, { "name": "money!", - "rust": "Decimal", "schema": "money", "col_type": "Money" + }, + { + "name": "money^", + "schema": "money_uniq", + "col_type": "MoneyUniq" + }, + { + "name": "unsigned!", + "schema": "unsigned", + "col_type": "Unsigned" + }, + { + "name": "unsigned", + "schema": "unsigned_null", + "col_type": "UnsignedNull" + }, + { + "name": "unsigned^", + "schema": "unsigned_uniq", + "col_type": "UnsignedUniq" + }, + { + "name": "binary_len!", + "schema": "binary_len", + "col_type": "BinaryLen", + "arity": 1 + }, + { + "name": "binary_len", + "schema": "binary_len_null", + "col_type": "BinaryLenNull", + "arity": 1 + }, + { + "name": "binary_len^", + "schema": "binary_len_uniq", + "col_type": "BinaryLenUniq", + "arity": 1 + }, + { + "name": "var_binary!", + "schema": "var_binary", + "col_type": "VarBinary", + "arity": 1 + }, + { + "name": "var_binary", + "schema": "var_binary_null", + "col_type": "VarBinaryNull", + "arity": 1 + }, + { + "name": "var_binary^", + "schema": "var_binary_uniq", + "col_type": "VarBinaryUniq", + "arity": 1 + }, + { + "name": "varbit_len!", + "schema": "varbit", + "col_type": "VarBitLen", + "arity": 1 + }, + { + "name": "varbit_len", + "schema": "varbit_null", + "col_type": "VarBitLenNull", + "arity": 1 + }, + { + "name": "varbit_len^", + "schema": "varbit_uniq", + "col_type": "VarBitLenUniq", + "arity": 1 + }, + { + "name": "array", + "schema": "array", + "col_type": "array_null", + "arity": 1 + }, + { + "name": "array!", + "schema": "array", + "col_type": "array", + "arity": 1 + }, + { + "name": "array^", + "schema": "array", + "col_type": "array_uniq", + "arity": 1 } ] -} +} \ No newline at end of file diff --git a/loco-gen/src/model.rs b/loco-gen/src/model.rs index ec812c8da..3f38c0c7b 100644 --- a/loco-gen/src/model.rs +++ b/loco-gen/src/model.rs @@ -2,6 +2,7 @@ use std::{collections::HashMap, env::current_dir, path::Path}; use chrono::Utc; use duct::cmd; +use heck::ToUpperCamelCase; use rrgen::RRgen; use serde_json::json; @@ -71,10 +72,30 @@ pub fn get_columns_and_references( ))); } - columns.push(( - fname.to_string(), - format!("{}({})", col_type, params.join(",")), - )); + let col = match ftype.as_ref() { + "array" | "array^" | "array!" => { + let array_kind = match params.as_slice() { + [array_kind] => Ok(array_kind), + _ => Err(Error::Message(format!( + "type: `{ftype}` requires exactly {arity} parameter{}, but {} were given (`{}`).", + if arity == 1 { "" } else { "s" }, + params.len(), + params.join(",") + ))), + }?; + + format!( + r#"{}(ArrayColType::{})"#, + col_type, + array_kind.to_upper_camel_case() + ) + } + &_ => { + format!("{}({})", col_type, params.join(",")) + } + }; + + columns.push((fname.to_string(), col)); } } } @@ -125,3 +146,110 @@ pub fn generate( Ok(gen_result) } + +#[cfg(test)] +mod tests { + use super::*; + + fn to_field(name: &str, field_type: &str) -> (String, String) { + (name.to_string(), field_type.to_string()) + } + + #[test] + fn test_get_columns_with_field_types() { + let fields = [ + to_field("expect_string_null", "string"), + to_field("expect_string", "string!"), + to_field("expect_unique", "string^"), + ]; + let res = get_columns_and_references(&fields).expect("Failed to parse fields"); + + let expected_columns = vec![ + to_field("expect_string_null", "StringNull"), + to_field("expect_string", "String"), + to_field("expect_unique", "StringUniq"), + ]; + let expected_references: Vec<(String, String)> = vec![]; + + assert_eq!(res, (expected_columns, expected_references)); + } + #[test] + fn test_get_columns_with_array_types() { + let fields = [ + to_field("expect_array_null", "array:string"), + to_field("expect_array", "array!:string"), + to_field("expect_array_uniq", "array^:string"), + ]; + let res = get_columns_and_references(&fields).expect("Failed to parse fields"); + + let expected_columns = vec![ + to_field("expect_array_null", "array_null(ArrayColType::String)"), + to_field("expect_array", "array(ArrayColType::String)"), + to_field("expect_array_uniq", "array_uniq(ArrayColType::String)"), + ]; + let expected_references: Vec<(String, String)> = vec![]; + + assert_eq!(res, (expected_columns, expected_references)); + } + + #[test] + fn test_get_references_from_fields() { + let fields = [ + to_field("user", "references"), + to_field("post", "references"), + ]; + let res = get_columns_and_references(&fields).expect("Failed to parse fields"); + + let expected_columns: Vec<(String, String)> = vec![]; + let expected_references = vec![to_field("user", ""), to_field("post", "")]; + + assert_eq!(res, (expected_columns, expected_references)); + } + + #[test] + fn test_ignore_fields_are_filtered_out() { + let mut fields = vec![to_field("name", "string")]; + + for ignore_field in IGNORE_FIELDS { + fields.push(to_field(ignore_field, "string")); + } + + let res = get_columns_and_references(&fields).expect("Failed to parse fields"); + + let expected_columns = vec![to_field("name", "StringNull")]; + let expected_references: Vec<(String, String)> = vec![]; + + assert_eq!(res, (expected_columns, expected_references)); + } + + #[test] + fn validate_arity() { + // field not expected arity, but given 2 + let fields = vec![to_field("name", "string:2")]; + let res = get_columns_and_references(&fields); + if let Err(err) = res { + assert_eq!( + err.to_string(), + "type: `string` requires specifying 0 parameters, but only 1 were given (`2`)." + ); + } else { + panic!("Expected Err, but got Ok: {res:?}"); + } + + // references not expected arity, but given 2 + let references = vec![to_field("post:2", "")]; + let res = get_columns_and_references(&references); + if let Err(err) = res { + let mappings = get_mappings(); + assert_eq!( + err.to_string(), + format!( + "type: `` not found. try any of: {:?}", + mappings.schema_fields() + ) + ); + } else { + panic!("Expected Err, but got Ok: {res:?}"); + } + } +} diff --git a/src/schema.rs b/src/schema.rs index 96ac2132f..809e4e6f9 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -4,7 +4,7 @@ use sea_orm::{ Alias, ColumnDef, Expr, Index, IntoIden, PgInterval, Table, TableAlterStatement, TableCreateStatement, TableForeignKey, }, - DbErr, ForeignKeyAction, + ColumnType, DbErr, ForeignKeyAction, }; pub use sea_orm_migration::schema::*; use sea_orm_migration::{prelude::Iden, sea_query, SchemaManager}; @@ -79,6 +79,18 @@ pub enum ColType { Integer, IntegerNull, IntegerUniq, + Unsigned, + UnsignedNull, + UnsignedUniq, + TinyUnsigned, + TinyUnsignedNull, + TinyUnsignedUniq, + SmallUnsigned, + SmallUnsignedNull, + SmallUnsignedUniq, + BigUnsigned, + BigUnsignedNull, + BigUnsignedUniq, TinyInteger, TinyIntegerNull, TinyIntegerUniq, @@ -108,6 +120,9 @@ pub enum ColType { Date, DateNull, DateUniq, + DateTime, + DateTimeNull, + DateTimeUniq, Time, TimeNull, TimeUniq, @@ -117,6 +132,12 @@ pub enum ColType { Binary, BinaryNull, BinaryUniq, + BinaryLen(u32), + BinaryLenNull(u32), + BinaryLenUniq(u32), + VarBinary(u32), + VarBinaryNull(u32), + VarBinaryUniq(u32), // Added variants based on the JSON TimestampWithTimeZone, TimestampWithTimeZoneNull, @@ -135,9 +156,72 @@ pub enum ColType { Uuid, UuidNull, UuidUniq, + VarBitLen(u32), + VarBitLenNull(u32), + VarBitLenUniq(u32), + Array(ColumnType), + ArrayNull(ColumnType), + ArrayUniq(ColumnType), +} + +pub enum ArrayColType { + String, + Text, + Char, + Float, + Int, + TinyInt, + SmallInt, + BigInt, + TinyUnsigned, + SmallUnsigned, + Unsigned, + BigUnsigned, + Double, + Boolean, +} + +impl ColType { + #[must_use] + #[allow(clippy::needless_pass_by_value)] + pub fn array(kind: ArrayColType) -> Self { + Self::Array(Self::array_col_type(&kind)) + } + + #[must_use] + #[allow(clippy::needless_pass_by_value)] + pub fn array_uniq(kind: ArrayColType) -> Self { + Self::ArrayUniq(Self::array_col_type(&kind)) + } + + #[must_use] + #[allow(clippy::needless_pass_by_value)] + pub fn array_null(kind: ArrayColType) -> Self { + Self::ArrayNull(Self::array_col_type(&kind)) + } + + fn array_col_type(kind: &ArrayColType) -> ColumnType { + match kind { + ArrayColType::String => ColumnType::string(None), + ArrayColType::Text => ColumnType::Text, + ArrayColType::Char => ColumnType::Char(None), + ArrayColType::Float => ColumnType::Float, + ArrayColType::Int => ColumnType::Integer, + ArrayColType::TinyInt => ColumnType::TinyInteger, + ArrayColType::SmallInt => ColumnType::SmallInteger, + ArrayColType::BigInt => ColumnType::BigInteger, + ArrayColType::TinyUnsigned => ColumnType::TinyUnsigned, + ArrayColType::SmallUnsigned => ColumnType::SmallUnsigned, + ArrayColType::Unsigned => ColumnType::Unsigned, + ArrayColType::BigUnsigned => ColumnType::BigUnsigned, + ArrayColType::Double => ColumnType::Double, + ArrayColType::Boolean => ColumnType::Boolean, + } + } } impl ColType { + #[allow(clippy::too_many_lines)] fn to_def(&self, name: impl IntoIden) -> ColumnDef { match self { Self::PkAuto => pk_auto(name), @@ -163,6 +247,18 @@ impl ColType { Self::TinyInteger => tiny_integer(name), Self::TinyIntegerNull => tiny_integer_null(name), Self::TinyIntegerUniq => tiny_integer_uniq(name), + Self::Unsigned => unsigned(name), + Self::UnsignedNull => unsigned_null(name), + Self::UnsignedUniq => unsigned_uniq(name), + Self::TinyUnsigned => tiny_unsigned(name), + Self::TinyUnsignedNull => tiny_unsigned_null(name), + Self::TinyUnsignedUniq => tiny_unsigned_uniq(name), + Self::SmallUnsigned => small_unsigned(name), + Self::SmallUnsignedNull => small_unsigned_null(name), + Self::SmallUnsignedUniq => small_unsigned_uniq(name), + Self::BigUnsigned => big_unsigned(name), + Self::BigUnsignedNull => big_unsigned_null(name), + Self::BigUnsignedUniq => big_unsigned_uniq(name), Self::SmallInteger => small_integer(name), Self::SmallIntegerNull => small_integer_null(name), Self::SmallIntegerUniq => small_integer_uniq(name), @@ -189,6 +285,9 @@ impl ColType { Self::Date => date(name), Self::DateNull => date_null(name), Self::DateUniq => date_uniq(name), + Self::DateTime => date_time(name), + Self::DateTimeNull => date_time_null(name), + Self::DateTimeUniq => date_time_uniq(name), Self::Time => time(name), Self::TimeNull => time_null(name), Self::TimeUniq => time_uniq(name), @@ -198,6 +297,12 @@ impl ColType { Self::Binary => binary(name), Self::BinaryNull => binary_null(name), Self::BinaryUniq => binary_uniq(name), + Self::BinaryLen(len) => binary_len(name, *len), + Self::BinaryLenNull(len) => binary_len_null(name, *len), + Self::BinaryLenUniq(len) => binary_len_uniq(name, *len), + Self::VarBinary(len) => var_binary(name, *len), + Self::VarBinaryNull(len) => var_binary_null(name, *len), + Self::VarBinaryUniq(len) => var_binary_uniq(name, *len), Self::TimestampWithTimeZone => timestamptz(name), Self::TimestampWithTimeZoneNull => timestamptz_null(name), Self::Json => json(name), @@ -215,6 +320,12 @@ impl ColType { Self::Uuid => uuid(name), Self::UuidNull => uuid_null(name), Self::UuidUniq => uuid_uniq(name), + Self::VarBitLen(len) => varbit(name, *len), + Self::VarBitLenNull(len) => varbit_null(name, *len), + Self::VarBitLenUniq(len) => varbit_uniq(name, *len), + Self::Array(kind) => array(name, kind.clone()), + Self::ArrayNull(kind) => array_null(name, kind.clone()), + Self::ArrayUniq(kind) => array_uniq(name, kind.clone()), } } } From df2579f695dd0e4e4bd68fb200919d7fac64a071 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Fri, 10 Jan 2025 16:36:19 +0200 Subject: [PATCH 02/26] clippy --- loco-gen/src/model.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/loco-gen/src/model.rs b/loco-gen/src/model.rs index 3f38c0c7b..317c33ad5 100644 --- a/loco-gen/src/model.rs +++ b/loco-gen/src/model.rs @@ -85,7 +85,7 @@ pub fn get_columns_and_references( }?; format!( - r#"{}(ArrayColType::{})"#, + r"{}(ArrayColType::{})", col_type, array_kind.to_upper_camel_case() ) From d2a9b0815556c2c671d3b2efdeb68bfaa35e4607 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Fri, 10 Jan 2025 22:19:06 +0200 Subject: [PATCH 03/26] revert rust field --- loco-gen/src/mappings.json | 72 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index 88b7c4a08..469dd06df 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -2,248 +2,297 @@ "field_types": [ { "name": "uuid", + "rust": "Uuid", "schema": "uuid_uniq", "col_type": "UuidUniq" }, { "name": "uuid_col", + "rust": "Option", "schema": "uuid_null", "col_type": "UuidNull" }, { "name": "uuid_col!", + "rust": "Uuid", "schema": "uuid", "col_type": "Uuid" }, { "name": "string", + "rust": "Option", "schema": "string_null", "col_type": "StringNull" }, { "name": "string!", + "rust": "String", "schema": "string", "col_type": "String" }, { "name": "string^", + "rust": "String", "schema": "string_uniq", "col_type": "StringUniq" }, { "name": "text", + "rust": "Option", "schema": "text_null", "col_type": "TextNull" }, { "name": "text!", + "rust": "String", "schema": "text", "col_type": "Text" }, { "name": "tiny_unsigned", + "rust": "Option", "schema": "tiny_unsigned_null", "col_type": "TinyUnsignedNull" }, { "name": "tiny_unsigned!", + "rust": "i16", "schema": "tiny_unsigned", "col_type": "TinyUnsigned" }, { "name": "tiny_unsigned^", + "rust": "i16", "schema": "tiny_unsigned_uniq", "col_type": "TinyUnsignedUniq" }, { "name": "small_unsigned", + "rust": "Option", "schema": "small_unsigned_null", "col_type": "SmallUnsignedNull" }, { "name": "small_unsigned!", + "rust": "i16", "schema": "small_unsigned", "col_type": "SmallUnsigned" }, { "name": "small_unsigned^", + "rust": "i16", "schema": "small_unsigned_uniq", "col_type": "SmallUnsignedUniq" }, { "name": "big_unsigned", + "rust": "Option", "schema": "big_unsigned_null", "col_type": "BigUnsignedNull" }, { "name": "big_unsigned!", + "rust": "i64", "schema": "big_unsigned", "col_type": "BigUnsigned" }, { "name": "big_unsigned^", + "rust": "i64", "schema": "big_unsigned_uniq", "col_type": "BigUnsignedUniq" }, { "name": "tiny_int", + "rust": "Option", "schema": "tiny_integer_null", "col_type": "TinyIntegerNull" }, { "name": "tiny_int!", + "rust": "i16", "schema": "tiny_integer", "col_type": "TinyInteger" }, { "name": "tiny_int^", + "rust": "i16", "schema": "tiny_integer_uniq", "col_type": "TinyIntegerUniq" }, { "name": "small_int", + "rust": "Option", "schema": "small_integer_null", "col_type": "SmallIntegerNull" }, { "name": "small_int!", + "rust": "i16", "schema": "small_integer", "col_type": "SmallInteger" }, { "name": "small_int^", + "rust": "i16", "schema": "small_integer_uniq", "col_type": "SmallIntegerUniq" }, { "name": "int", + "rust": "Option", "schema": "integer_null", "col_type": "IntegerNull" }, { "name": "int!", + "rust": "i32", "schema": "integer", "col_type": "Integer" }, { "name": "int^", + "rust": "i32", "schema": "integer_uniq", "col_type": "IntegerUniq" }, { "name": "big_int", + "rust": "Option", "schema": "big_integer_null", "col_type": "BigIntegerNull" }, { "name": "big_int!", + "rust": "i64", "schema": "big_integer", "col_type": "BigInteger" }, { "name": "big_int^", + "rust": "i64", "schema": "big_integer_uniq", "col_type": "BigIntegerUniq" }, { "name": "float", + "rust": "Option", "schema": "float_null", "col_type": "FloatNull" }, { "name": "float!", + "rust": "f32", "schema": "float", "col_type": "Float" }, { "name": "double", + "rust": "Option", "schema": "double_null", "col_type": "DoubleNull" }, { "name": "double!", + "rust": "f64", "schema": "double", "col_type": "Double" }, { "name": "decimal", + "rust": "Option", "schema": "decimal_null", "col_type": "DecimalNull" }, { "name": "decimal!", + "rust": "Decimal", "schema": "decimal", "col_type": "Decimal" }, { "name": "decimal_len", + "rust": "Option", "schema": "decimal_len_null", "col_type": "DecimalLenNull", "arity": 2 }, { "name": "decimal_len!", + "rust": "Decimal", "schema": "decimal_len", "col_type": "DecimalLen", "arity": 2 }, { "name": "bool", + "rust": "Option", "schema": "boolean_null", "col_type": "BooleanNull" }, { "name": "bool!", + "rust": "bool", "schema": "boolean", "col_type": "Boolean" }, { "name": "tstz", + "rust": "Option", "schema": "timestamp_with_time_zone_null", "col_type": "TimestampWithTimeZoneNull" }, { "name": "tstz!", + "rust": "DateTimeWithTimeZone", "schema": "timestamp_with_time_zone", "col_type": "TimestampWithTimeZone" }, { "name": "date", + "rust": "Option", "schema": "date_null", "col_type": "DateNull" }, { "name": "date!", + "rust": "Date", "schema": "date", "col_type": "Date" }, { "name": "date^", + "rust": "Date", "schema": "date_uniq", "col_type": "DateUniq" }, { "name": "date_time", + "rust": "Option", "schema": "date_time_null", "col_type": "DateTimeNull" }, { "name": "date_time!", + "rust": "DateTime", "schema": "date_time", "col_type": "DateTime" }, { "name": "date_time^", + "rust": "DateTime", "schema": "date_time_uniq", "col_type": "DateTimeUniq" }, { "name": "ts", + "rust": "Option", "schema": "timestamp_null", "col_type": "TimestampNull" }, { "name": "ts!", + "rust": "DateTime", "schema": "timestamp", "col_type": "Timestamp" }, @@ -255,127 +304,150 @@ }, { "name": "json!", + "rust": "serde_json::Value", "schema": "json", "col_type": "Json" }, { "name": "jsonb", + "rust": "Option", "schema": "json_binary_null", "col_type": "JsonBinaryNull" }, { "name": "jsonb!", + "rust": "serde_json::Value", "schema": "json_binary", "col_type": "JsonBinary" }, { "name": "blob", + "rust": "Option>", "schema": "blob_null", "col_type": "BlobNull" }, { "name": "blob!", + "rust": "Vec", "schema": "blob", "col_type": "Blob" }, { "name": "money", + "rust": "Option", "schema": "money_null", "col_type": "MoneyNull" }, { "name": "money!", + "rust": "Decimal", "schema": "money", "col_type": "Money" }, { "name": "money^", + "rust": "Decimal", "schema": "money_uniq", "col_type": "MoneyUniq" }, { "name": "unsigned!", + "rust": "i32", "schema": "unsigned", "col_type": "Unsigned" }, { "name": "unsigned", + "rust": "Option", "schema": "unsigned_null", "col_type": "UnsignedNull" }, { "name": "unsigned^", + "rust": "i32", "schema": "unsigned_uniq", "col_type": "UnsignedUniq" }, { "name": "binary_len!", + "rust": "Vec", "schema": "binary_len", "col_type": "BinaryLen", "arity": 1 }, { "name": "binary_len", + "rust": "Option>", "schema": "binary_len_null", "col_type": "BinaryLenNull", "arity": 1 }, { "name": "binary_len^", + "rust": "Vec", "schema": "binary_len_uniq", "col_type": "BinaryLenUniq", "arity": 1 }, { "name": "var_binary!", + "rust": "Vec", "schema": "var_binary", "col_type": "VarBinary", "arity": 1 }, { "name": "var_binary", + "rust": "Option>", "schema": "var_binary_null", "col_type": "VarBinaryNull", "arity": 1 }, { "name": "var_binary^", + "rust": "Vec", "schema": "var_binary_uniq", "col_type": "VarBinaryUniq", "arity": 1 }, { "name": "varbit_len!", + "rust": "Vec", "schema": "varbit", "col_type": "VarBitLen", "arity": 1 }, { "name": "varbit_len", + "rust": "Option>", "schema": "varbit_null", "col_type": "VarBitLenNull", "arity": 1 }, { "name": "varbit_len^", + "rust": "Vec", "schema": "varbit_uniq", "col_type": "VarBitLenUniq", "arity": 1 }, { "name": "array", + "rust": "Option>", "schema": "array", "col_type": "array_null", "arity": 1 }, { "name": "array!", + "rust": "Option>", "schema": "array", "col_type": "array", "arity": 1 }, { "name": "array^", + "rust": "Option>", "schema": "array", "col_type": "array_uniq", "arity": 1 From 331a005b313e4cab38795de11b1b407dad874027 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 13 Jan 2025 17:45:07 +0200 Subject: [PATCH 04/26] adding rust types for array --- loco-gen/src/lib.rs | 268 ++++++++++++++++++++++++++++++++++--- loco-gen/src/mappings.json | 44 +++++- loco-gen/src/model.rs | 16 +-- loco-gen/src/scaffold.rs | 16 +-- src/schema.rs | 10 -- 5 files changed, 294 insertions(+), 60 deletions(-) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 0dc912430..bb3f3fe44 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -8,6 +8,7 @@ use serde_json::{json, Value}; mod controller; use colored::Colorize; use std::{ + collections::HashMap, fs, path::{Path, PathBuf}, str::FromStr, @@ -64,48 +65,105 @@ pub type Result = std::result::Result; #[derive(Serialize, Deserialize, Debug)] struct FieldType { name: String, - rust: Option, - schema: Option, - col_type: Option, + rust: RustType, + schema: String, + col_type: String, #[serde(default)] arity: usize, } +#[derive(Debug, Deserialize, Serialize)] +#[serde(untagged)] +enum RustType { + String(String), + Map(HashMap), +} + #[derive(Serialize, Deserialize, Debug)] struct Mappings { field_types: Vec, } impl Mappings { - pub fn rust_field(&self, field: &str) -> Option<&String> { + fn error_unrecognized_default_field(&self, field: &str) -> Error { + Self::error_unrecognized(field, self.schema_fields()) + } + fn error_unrecognized(field: &str, allow_fields: Vec<&String>) -> Error { + Error::Message(format!( + "type: `{}` not found. try any of: `{}`", + field, + allow_fields + .iter() + .map(|&s| s.to_string()) + .collect::>() + .join(",") + )) + } + pub fn rust_field_with_params(&self, field: &str, params: &Vec) -> Result<&str> { + match field { + "array" | "array^" | "array!" => { + if let RustType::Map(ref map) = self.rust_field_kind(field)? { + if let [single] = params.as_slice() { + Ok(map + .get(single) + .ok_or_else(|| Self::error_unrecognized(field, map.keys().collect()))?) + } else { + Err(self.error_unrecognized_default_field(field)) + } + } else { + panic!("array field should configured as array") + } + } + + _ => self.rust_field(field), + } + } + + pub fn rust_field_kind(&self, field: &str) -> Result<&RustType> { self.field_types .iter() .find(|f| f.name == field) - .and_then(|f| f.rust.as_ref()) + .map(|f| &f.rust) + .ok_or_else(|| self.error_unrecognized_default_field(field)) } - pub fn schema_field(&self, field: &str) -> Option<&String> { + + pub fn rust_field(&self, field: &str) -> Result<&str> { self.field_types .iter() .find(|f| f.name == field) - .and_then(|f| f.schema.as_ref()) + .map(|f| &f.rust) + .ok_or_else(|| self.error_unrecognized_default_field(field)) + .and_then(|rust_type| match rust_type { + RustType::String(s) => Ok(s), + RustType::Map(_) => Err(Error::Message(format!( + "type `{field}` need params to get the rust field type" + ))), + }) + .map(std::string::String::as_str) } - pub fn col_type_field(&self, field: &str) -> Option<&String> { + + pub fn schema_field(&self, field: &str) -> Result<&str> { self.field_types .iter() .find(|f| f.name == field) - .and_then(|f| f.col_type.as_ref()) + .map(|f| f.schema.as_str()) + .ok_or_else(|| self.error_unrecognized_default_field(field)) } - pub fn col_type_arity(&self, field: &str) -> Option { + pub fn col_type_field(&self, field: &str) -> Result<&str> { self.field_types .iter() .find(|f| f.name == field) - .map(|f| f.arity) + .map(|f| f.col_type.as_str()) + .ok_or_else(|| self.error_unrecognized_default_field(field)) } - pub fn schema_fields(&self) -> Vec<&String> { + pub fn col_type_arity(&self, field: &str) -> Result { self.field_types .iter() - .filter(|f| f.schema.is_some()) - .map(|f| &f.name) - .collect::>() + .find(|f| f.name == field) + .map(|f| f.arity) + .ok_or_else(|| self.error_unrecognized_default_field(field)) + } + pub fn schema_fields(&self) -> Vec<&String> { + self.field_types.iter().map(|f| &f.name).collect::>() } } @@ -475,4 +533,184 @@ mod tests { ); } } + + fn test_mapping() -> Mappings { + Mappings { + field_types: vec![ + FieldType { + name: "array".to_string(), + rust: RustType::Map(HashMap::from([ + ("string".to_string(), "Vec".to_string()), + ("chat".to_string(), "Vec".to_string()), + ("int".to_string(), "Vec".to_string()), + ])), + schema: "array".to_string(), + col_type: "array_null".to_string(), + arity: 1, + }, + FieldType { + name: "string^".to_string(), + rust: RustType::String("String".to_string()), + schema: "string_uniq".to_string(), + col_type: "StringUniq".to_string(), + arity: 0, + }, + ], + } + } + + #[test] + fn can_get_schema_fields_from_mapping() { + let mapping = test_mapping(); + assert_eq!( + mapping.schema_fields(), + Vec::from([&"array".to_string(), &"string^".to_string()]) + ); + } + + #[test] + fn can_get_col_type_arity_from_mapping() { + let mapping = test_mapping(); + + assert_eq!(mapping.col_type_arity("array").expect("Get array arity"), 1); + assert_eq!( + mapping + .col_type_arity("string^") + .expect("Get string^ arity"), + 0 + ); + + assert_eq!( + mapping + .col_type_arity("unknown") + .expect_err("expect error") + .to_string(), + mapping + .error_unrecognized_default_field("unknown") + .to_string() + ); + } + + #[test] + fn can_get_col_type_field_from_mapping() { + let mapping = test_mapping(); + + assert_eq!( + mapping.col_type_field("array").expect("Get array field"), + "array_null" + ); + + assert_eq!( + mapping + .col_type_field("unknown") + .expect_err("expect error") + .to_string(), + mapping + .error_unrecognized_default_field("unknown") + .to_string() + ); + } + + #[test] + fn can_get_schema_field_from_mapping() { + let mapping = test_mapping(); + + assert_eq!( + mapping.schema_field("string^").expect("Get string^ schema"), + "string_uniq" + ); + + assert_eq!( + mapping + .schema_field("unknown") + .expect_err("expect error") + .to_string(), + mapping + .error_unrecognized_default_field("unknown") + .to_string() + ); + } + + #[test] + fn can_get_rust_field_from_mapping() { + let mapping = test_mapping(); + + assert_eq!( + mapping + .rust_field("string^") + .expect("Get string^ rust field"), + "String" + ); + + assert_eq!( + mapping + .rust_field("array") + .expect_err("expect error") + .to_string(), + "type `array` need params to get the rust field type".to_string() + ); + + assert_eq!( + mapping + .rust_field("unknown") + .expect_err("expect error") + .to_string(), + mapping + .error_unrecognized_default_field("unknown") + .to_string() + ); + } + + #[test] + fn can_get_rust_field_kind_from_mapping() { + let mapping = test_mapping(); + + assert!(mapping.rust_field_kind("string^").is_ok()); + + assert_eq!( + mapping + .rust_field_kind("unknown") + .expect_err("expect error") + .to_string(), + mapping + .error_unrecognized_default_field("unknown") + .to_string() + ); + } + + #[test] + fn can_get_rust_field_with_params_from_mapping() { + let mapping = test_mapping(); + + assert_eq!( + mapping + .rust_field_with_params("string^", &vec!["string".to_string()]) + .expect("Get string^ rust field"), + "String" + ); + + assert_eq!( + mapping + .rust_field_with_params("array", &vec!["string".to_string()]) + .expect("Get string^ rust field"), + "Vec" + ); + assert_eq!( + mapping + .rust_field_with_params("array", &vec!["unknown".to_string()]) + .expect_err("expect error") + .to_string(), + "type: `array` not found. try any of: `int,string,chat`" + ); + + assert_eq!( + mapping + .rust_field_with_params("unknown", &vec![]) + .expect_err("expect error") + .to_string(), + mapping + .error_unrecognized_default_field("unknown") + .to_string() + ); + } } diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index 469dd06df..97888ad83 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -432,22 +432,52 @@ "arity": 1 }, { - "name": "array", - "rust": "Option>", + "name": "array!", + "rust": { + "string": "Vec", + "char": "Vec", + "text": "Vec", + "float": "Vec", + "int": "Vec", + "small_int": "Vec", + "big_int": "Vec", + "double": "Vec", + "bool": "Vec" + }, "schema": "array", - "col_type": "array_null", + "col_type": "array", "arity": 1 }, { - "name": "array!", - "rust": "Option>", + "name": "array", + "rust": { + "string": "Option>", + "char": "Option>", + "text": "Option>", + "float": "Option>", + "int": "Option>", + "small_int": "Option>", + "big_int": "Option>", + "double": "Option>", + "bool": "Option>" + }, "schema": "array", - "col_type": "array", + "col_type": "array_null", "arity": 1 }, { "name": "array^", - "rust": "Option>", + "rust": { + "string": "Vec", + "char": "Vec", + "text": "Vec", + "float": "Vec", + "int": "Vec", + "small_int": "Vec", + "big_int": "Vec", + "double": "Vec", + "bool": "Vec" + }, "schema": "array", "col_type": "array_uniq", "arity": 1 diff --git a/loco-gen/src/model.rs b/loco-gen/src/model.rs index 317c33ad5..4c813226a 100644 --- a/loco-gen/src/model.rs +++ b/loco-gen/src/model.rs @@ -44,24 +44,12 @@ pub fn get_columns_and_references( } crate::infer::FieldType::Type(ftype) => { let mappings = get_mappings(); - let col_type = mappings.col_type_field(ftype.as_str()).ok_or_else(|| { - Error::Message(format!( - "type: `{}` not found. try any of: {:?}", - ftype, - mappings.schema_fields() - )) - })?; + let col_type = mappings.col_type_field(ftype.as_str())?; columns.push((fname.to_string(), col_type.to_string())); } crate::infer::FieldType::TypeWithParameters(ftype, params) => { let mappings = get_mappings(); - let col_type = mappings.col_type_field(ftype.as_str()).ok_or_else(|| { - Error::Message(format!( - "type: `{}` not found. try any of: {:?}", - ftype, - mappings.schema_fields() - )) - })?; + let col_type = mappings.col_type_field(ftype.as_str())?; let arity = mappings.col_type_arity(ftype.as_str()).unwrap_or_default(); if params.len() != arity { return Err(Error::Message(format!( diff --git a/loco-gen/src/scaffold.rs b/loco-gen/src/scaffold.rs index 4e03e18cc..40f4d5d3e 100644 --- a/loco-gen/src/scaffold.rs +++ b/loco-gen/src/scaffold.rs @@ -41,24 +41,12 @@ pub fn generate( } crate::infer::FieldType::Type(ftype) => { let mappings = get_mappings(); - let rust_type = mappings.rust_field(ftype.as_str()).ok_or_else(|| { - Error::Message(format!( - "type: `{}` not found. try any of: {:?}", - ftype, - mappings.schema_fields() - )) - })?; + let rust_type = mappings.rust_field(ftype.as_str())?; columns.push((fname.to_string(), rust_type.to_string(), ftype)); } crate::infer::FieldType::TypeWithParameters(ftype, params) => { let mappings = get_mappings(); - let rust_type = mappings.rust_field(ftype.as_str()).ok_or_else(|| { - Error::Message(format!( - "type: `{}` not found. try any of: {:?}", - ftype, - mappings.schema_fields() - )) - })?; + let rust_type = mappings.rust_field_with_params(ftype.as_str(), ¶ms)?; let arity = mappings.col_type_arity(ftype.as_str()).unwrap_or_default(); if params.len() != arity { return Err(Error::Message(format!( diff --git a/src/schema.rs b/src/schema.rs index 809e4e6f9..cf572ffc4 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -170,13 +170,8 @@ pub enum ArrayColType { Char, Float, Int, - TinyInt, SmallInt, BigInt, - TinyUnsigned, - SmallUnsigned, - Unsigned, - BigUnsigned, Double, Boolean, } @@ -207,13 +202,8 @@ impl ColType { ArrayColType::Char => ColumnType::Char(None), ArrayColType::Float => ColumnType::Float, ArrayColType::Int => ColumnType::Integer, - ArrayColType::TinyInt => ColumnType::TinyInteger, ArrayColType::SmallInt => ColumnType::SmallInteger, ArrayColType::BigInt => ColumnType::BigInteger, - ArrayColType::TinyUnsigned => ColumnType::TinyUnsigned, - ArrayColType::SmallUnsigned => ColumnType::SmallUnsigned, - ArrayColType::Unsigned => ColumnType::Unsigned, - ArrayColType::BigUnsigned => ColumnType::BigUnsigned, ArrayColType::Double => ColumnType::Double, ArrayColType::Boolean => ColumnType::Boolean, } From 6fc81338e58e886fa614bd17378f7883ed48a718 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 13 Jan 2025 19:04:33 +0200 Subject: [PATCH 05/26] scaffold ui --- .../src/templates/scaffold/html/view_create.t | 30 +++++++++++- .../src/templates/scaffold/html/view_edit.t | 31 +++++++++++- .../src/templates/scaffold/htmx/view_create.t | 45 +++++++++++++++-- .../src/templates/scaffold/htmx/view_edit.t | 48 ++++++++++++++++++- 4 files changed, 146 insertions(+), 8 deletions(-) diff --git a/loco-gen/src/templates/scaffold/html/view_create.t b/loco-gen/src/templates/scaffold/html/view_create.t index 5095be362..c9bb56b9e 100644 --- a/loco-gen/src/templates/scaffold/html/view_create.t +++ b/loco-gen/src/templates/scaffold/html/view_create.t @@ -43,6 +43,16 @@ Create {{file_name}} {% elif column.2 == "json!" or column.2 == "jsonb!" -%} + {% elif column.2 == "array!" or column.2 == "array^" -%} +
+ +
+ + {% elif column.2 == "array" -%} +
+ +
+ {% endif -%} {% endfor -%} @@ -54,4 +64,22 @@ Create {{file_name}}
Back to {{name | plural}} -{% raw %}{% endblock content %}{% endraw %} \ No newline at end of file +{% raw %}{% endblock content %}{% endraw %} + +{% raw %}{% block js %}{% endraw %} + +{% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/html/view_edit.t b/loco-gen/src/templates/scaffold/html/view_edit.t index 20145738d..dbd7725fd 100644 --- a/loco-gen/src/templates/scaffold/html/view_edit.t +++ b/loco-gen/src/templates/scaffold/html/view_edit.t @@ -43,8 +43,23 @@ Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} {% elif column.2 == "json!" or column.2 == "jsonb!" -%} + {% elif column.2 == "array!" or column.2 == "array^" -%} +
+ {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} + + {% raw %}{% endfor -%}{% endraw %} +
+ + {% elif column.2 == "array" -%} +
+ {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} + + {% raw %}{% endfor -%}{% endraw %} +
+ + {% endif -%} - {% endif -%} + {% endfor -%}
@@ -74,5 +89,19 @@ function confirmDelete(event) { xhr.send(); } } + + document.addEventListener('DOMContentLoaded', function () { + document.querySelectorAll('.add-more').forEach(button => { + button.addEventListener('click', function () { + const group = this.getAttribute('data-group'); + const container = document.getElementById(`${group}-inputs`); + const newInput = document.createElement('input'); + newInput.type = 'text'; + newInput.name = `${group}[]`; + newInput.placeholder = `Enter another ${group} value`; + container.appendChild(newInput); + }); + }); + }); {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/htmx/view_create.t b/loco-gen/src/templates/scaffold/htmx/view_create.t index 7e638a116..70a95cf93 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_create.t +++ b/loco-gen/src/templates/scaffold/htmx/view_create.t @@ -43,6 +43,16 @@ Create {{file_name}} {% elif column.2 == "json!" or column.2 == "jsonb!" -%} + {% elif column.2 == "array!" or column.2 == "array^" -%} +
+ +
+ + {% elif column.2 == "array" -%} +
+ +
+ {% endif -%}
{% endfor -%} @@ -59,23 +69,50 @@ Create {{file_name}} htmx.defineExtension('submitjson', { onEvent: function (name, evt) { if (name === "htmx:configRequest") { - evt.detail.headers['Content-Type'] = "application/json" + evt.detail.headers['Content-Type'] = "application/json"; } }, encodeParameters: function (xhr, parameters, elt) { const json = {}; + // Handle individual field inputs for (const [key, value] of Object.entries(parameters)) { - const inputType = elt.querySelector(`[name=${key}]`).type; + const inputType = elt.querySelector(`[name="${key}"]`).type; if (inputType === 'number') { json[key] = parseFloat(value); } else if (inputType === 'checkbox') { - json[key] = elt.querySelector(`[name=${key}]`).checked; + json[key] = elt.querySelector(`[name="${key}"]`).checked; } else { json[key] = value; } } + + elt.querySelectorAll('[name]').forEach(input => { + if (input.name.endsWith('[]')) { + const group = input.name.split('[')[0]; // Extract group name + + if (!json[group]) { + json[group] = []; + } + json[group].push(input.value); + } + }); + return JSON.stringify(json); } - }) + }); + + document.addEventListener('DOMContentLoaded', function () { + document.querySelectorAll('.add-more').forEach(button => { + button.addEventListener('click', function () { + const group = this.getAttribute('data-group'); + const container = document.getElementById(`${group}-inputs`); + const newInput = document.createElement('input'); + newInput.type = 'text'; + newInput.name = `${group}[]`; + newInput.placeholder = `Enter another ${group} value`; + container.appendChild(newInput); + }); + }); + }); {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/htmx/view_edit.t b/loco-gen/src/templates/scaffold/htmx/view_edit.t index aa202ee3d..58f97ef35 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_edit.t +++ b/loco-gen/src/templates/scaffold/htmx/view_edit.t @@ -43,6 +43,22 @@ Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} {% elif column.2 == "json!" or column.2 == "jsonb!" -%} + {% elif column.2 == "array!" or column.2 == "array^" -%} +
+ {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} + + {% raw %}{% endfor -%}{% endraw %} +
+ + {% elif column.2 == "array" -%} +
+ {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} + + {% raw %}{% endfor -%}{% endraw %} +
+ {% endif -%} {% endfor -%} @@ -71,16 +87,30 @@ Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} }, encodeParameters: function (xhr, parameters, elt) { const json = {}; + // Handle individual field inputs for (const [key, value] of Object.entries(parameters)) { - const inputType = elt.querySelector(`[name=${key}]`).type; + const inputType = elt.querySelector(`[name="${key}"]`).type; if (inputType === 'number') { json[key] = parseFloat(value); } else if (inputType === 'checkbox') { - json[key] = elt.querySelector(`[name=${key}]`).checked; + json[key] = elt.querySelector(`[name="${key}"]`).checked; } else { json[key] = value; } } + + // Handle array inputs dynamically based on the name + elt.querySelectorAll('[name]').forEach(input => { + if (input.name.endsWith('[]')) { + const group = input.name.split('[')[0]; // Extract group name + + if (!json[group]) { + json[group] = []; + } + json[group].push(input.value); + } + }); + return JSON.stringify(json); } }) @@ -97,5 +127,19 @@ Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} xhr.send(); } } + + document.addEventListener('DOMContentLoaded', function () { + document.querySelectorAll('.add-more').forEach(button => { + button.addEventListener('click', function () { + const group = this.getAttribute('data-group'); + const container = document.getElementById(`${group}-inputs`); + const newInput = document.createElement('input'); + newInput.type = 'text'; + newInput.name = `${group}[]`; + newInput.placeholder = `Enter another ${group} value`; + container.appendChild(newInput); + }); + }); + }); {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file From a21450ee977c04ab8afeb1803858da33fd834842 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 13 Jan 2025 19:28:14 +0200 Subject: [PATCH 06/26] clippy fixes --- loco-gen/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index bb3f3fe44..3842df3a9 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -85,9 +85,9 @@ struct Mappings { } impl Mappings { fn error_unrecognized_default_field(&self, field: &str) -> Error { - Self::error_unrecognized(field, self.schema_fields()) + Self::error_unrecognized(field, &self.schema_fields()) } - fn error_unrecognized(field: &str, allow_fields: Vec<&String>) -> Error { + fn error_unrecognized(field: &str, allow_fields: &[&String]) -> Error { Error::Message(format!( "type: `{}` not found. try any of: `{}`", field, @@ -103,9 +103,10 @@ impl Mappings { "array" | "array^" | "array!" => { if let RustType::Map(ref map) = self.rust_field_kind(field)? { if let [single] = params.as_slice() { + let keys: Vec<&String> = map.keys().collect(); Ok(map .get(single) - .ok_or_else(|| Self::error_unrecognized(field, map.keys().collect()))?) + .ok_or_else(|| Self::error_unrecognized(field, &keys))?) } else { Err(self.error_unrecognized_default_field(field)) } From 00441725e3bd24d512e6849c232ee3dd6f0970d9 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 13 Jan 2025 19:49:29 +0200 Subject: [PATCH 07/26] test --- loco-gen/src/model.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/loco-gen/src/model.rs b/loco-gen/src/model.rs index 4c813226a..5b18b9a66 100644 --- a/loco-gen/src/model.rs +++ b/loco-gen/src/model.rs @@ -231,10 +231,7 @@ mod tests { let mappings = get_mappings(); assert_eq!( err.to_string(), - format!( - "type: `` not found. try any of: {:?}", - mappings.schema_fields() - ) + mappings.error_unrecognized_default_field("").to_string() ); } else { panic!("Expected Err, but got Ok: {res:?}"); From 58bec24c97c9b0c3ab2b1d54647ad8b5707f90dd Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 13 Jan 2025 20:12:32 +0200 Subject: [PATCH 08/26] test --- loco-gen/src/lib.rs | 60 +++++---------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 3842df3a9..2a6a907ed 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -581,15 +581,7 @@ mod tests { 0 ); - assert_eq!( - mapping - .col_type_arity("unknown") - .expect_err("expect error") - .to_string(), - mapping - .error_unrecognized_default_field("unknown") - .to_string() - ); + assert!(mapping.col_type_arity("unknown").is_err()); } #[test] @@ -601,15 +593,7 @@ mod tests { "array_null" ); - assert_eq!( - mapping - .col_type_field("unknown") - .expect_err("expect error") - .to_string(), - mapping - .error_unrecognized_default_field("unknown") - .to_string() - ); + assert!(mapping.col_type_field("unknown").is_err()); } #[test] @@ -621,15 +605,7 @@ mod tests { "string_uniq" ); - assert_eq!( - mapping - .schema_field("unknown") - .expect_err("expect error") - .to_string(), - mapping - .error_unrecognized_default_field("unknown") - .to_string() - ); + assert!(mapping.schema_field("unknown").is_err()); } #[test] @@ -651,15 +627,7 @@ mod tests { "type `array` need params to get the rust field type".to_string() ); - assert_eq!( - mapping - .rust_field("unknown") - .expect_err("expect error") - .to_string(), - mapping - .error_unrecognized_default_field("unknown") - .to_string() - ); + assert!(mapping.rust_field("unknown").is_err(),); } #[test] @@ -668,15 +636,7 @@ mod tests { assert!(mapping.rust_field_kind("string^").is_ok()); - assert_eq!( - mapping - .rust_field_kind("unknown") - .expect_err("expect error") - .to_string(), - mapping - .error_unrecognized_default_field("unknown") - .to_string() - ); + assert!(mapping.rust_field_kind("unknown").is_err(),); } #[test] @@ -704,14 +664,6 @@ mod tests { "type: `array` not found. try any of: `int,string,chat`" ); - assert_eq!( - mapping - .rust_field_with_params("unknown", &vec![]) - .expect_err("expect error") - .to_string(), - mapping - .error_unrecognized_default_field("unknown") - .to_string() - ); + assert!(mapping.rust_field_with_params("unknown", &vec![]).is_err()); } } From 201b17b52ce71480601db5a728178668bd9b95d2 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 13 Jan 2025 20:20:31 +0200 Subject: [PATCH 09/26] test --- loco-gen/src/lib.rs | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 2a6a907ed..cf7f9fac0 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -619,13 +619,7 @@ mod tests { "String" ); - assert_eq!( - mapping - .rust_field("array") - .expect_err("expect error") - .to_string(), - "type `array` need params to get the rust field type".to_string() - ); + assert!(mapping.rust_field("array").is_err()); assert!(mapping.rust_field("unknown").is_err(),); } @@ -656,13 +650,9 @@ mod tests { .expect("Get string^ rust field"), "Vec" ); - assert_eq!( - mapping - .rust_field_with_params("array", &vec!["unknown".to_string()]) - .expect_err("expect error") - .to_string(), - "type: `array` not found. try any of: `int,string,chat`" - ); + assert!(mapping + .rust_field_with_params("array", &vec!["unknown".to_string()]) + .is_err()); assert!(mapping.rust_field_with_params("unknown", &vec![]).is_err()); } From fe89071ea6851bc24a8edbc53f9d270b9821c11c Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Tue, 14 Jan 2025 08:42:35 +0200 Subject: [PATCH 10/26] test --- .../src/templates/scaffold/htmx/view_create.t | 5 ++- ...enerate[views_[create]]@Html_scaffold.snap | 18 +++++++++++ ...enerate[views_[create]]@Htmx_scaffold.snap | 30 +++++++++++++++-- .../generate[views_[edit]]@Html_scaffold.snap | 16 ++++++++++ .../generate[views_[edit]]@Htmx_scaffold.snap | 32 +++++++++++++++++-- 5 files changed, 94 insertions(+), 7 deletions(-) diff --git a/loco-gen/src/templates/scaffold/htmx/view_create.t b/loco-gen/src/templates/scaffold/htmx/view_create.t index 70a95cf93..3fbdb1978 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_create.t +++ b/loco-gen/src/templates/scaffold/htmx/view_create.t @@ -74,13 +74,12 @@ Create {{file_name}} }, encodeParameters: function (xhr, parameters, elt) { const json = {}; - // Handle individual field inputs for (const [key, value] of Object.entries(parameters)) { - const inputType = elt.querySelector(`[name="${key}"]`).type; + const inputType = elt.querySelector(`[name=${key}]`).type; if (inputType === 'number') { json[key] = parseFloat(value); } else if (inputType === 'checkbox') { - json[key] = elt.querySelector(`[name="${key}"]`).checked; + json[key] = elt.querySelector(`[name=${key}]`).checked; } else { json[key] = value; } diff --git a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap index 2a9fd91b7..cb61380dd 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap @@ -27,3 +27,21 @@ Create movie Back to movies {% endblock content %} + +{% block js %} + +{% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap index 162098eac..384b96012 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap @@ -31,7 +31,7 @@ Create movie htmx.defineExtension('submitjson', { onEvent: function (name, evt) { if (name === "htmx:configRequest") { - evt.detail.headers['Content-Type'] = "application/json" + evt.detail.headers['Content-Type'] = "application/json"; } }, encodeParameters: function (xhr, parameters, elt) { @@ -46,8 +46,34 @@ Create movie json[key] = value; } } + + elt.querySelectorAll('[name]').forEach(input => { + if (input.name.endsWith('[]')) { + const group = input.name.split('[')[0]; // Extract group name + + if (!json[group]) { + json[group] = []; + } + json[group].push(input.value); + } + }); + return JSON.stringify(json); } - }) + }); + + document.addEventListener('DOMContentLoaded', function () { + document.querySelectorAll('.add-more').forEach(button => { + button.addEventListener('click', function () { + const group = this.getAttribute('data-group'); + const container = document.getElementById(`${group}-inputs`); + const newInput = document.createElement('input'); + newInput.type = 'text'; + newInput.name = `${group}[]`; + newInput.placeholder = `Enter another ${group} value`; + container.appendChild(newInput); + }); + }); + }); {% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap index 404bad6af..86f992247 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap @@ -18,6 +18,8 @@ Edit movie: {{ item.id }}
+ +
@@ -45,5 +47,19 @@ function confirmDelete(event) { xhr.send(); } } + + document.addEventListener('DOMContentLoaded', function () { + document.querySelectorAll('.add-more').forEach(button => { + button.addEventListener('click', function () { + const group = this.getAttribute('data-group'); + const container = document.getElementById(`${group}-inputs`); + const newInput = document.createElement('input'); + newInput.type = 'text'; + newInput.name = `${group}[]`; + newInput.placeholder = `Enter another ${group} value`; + container.appendChild(newInput); + }); + }); + }); {% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap index 2c097aa50..9a65856ff 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap @@ -43,16 +43,30 @@ Edit movie: {{ item.id }} }, encodeParameters: function (xhr, parameters, elt) { const json = {}; + // Handle individual field inputs for (const [key, value] of Object.entries(parameters)) { - const inputType = elt.querySelector(`[name=${key}]`).type; + const inputType = elt.querySelector(`[name="${key}"]`).type; if (inputType === 'number') { json[key] = parseFloat(value); } else if (inputType === 'checkbox') { - json[key] = elt.querySelector(`[name=${key}]`).checked; + json[key] = elt.querySelector(`[name="${key}"]`).checked; } else { json[key] = value; } } + + // Handle array inputs dynamically based on the name + elt.querySelectorAll('[name]').forEach(input => { + if (input.name.endsWith('[]')) { + const group = input.name.split('[')[0]; // Extract group name + + if (!json[group]) { + json[group] = []; + } + json[group].push(input.value); + } + }); + return JSON.stringify(json); } }) @@ -69,5 +83,19 @@ Edit movie: {{ item.id }} xhr.send(); } } + + document.addEventListener('DOMContentLoaded', function () { + document.querySelectorAll('.add-more').forEach(button => { + button.addEventListener('click', function () { + const group = this.getAttribute('data-group'); + const container = document.getElementById(`${group}-inputs`); + const newInput = document.createElement('input'); + newInput.type = 'text'; + newInput.name = `${group}[]`; + newInput.placeholder = `Enter another ${group} value`; + container.appendChild(newInput); + }); + }); + }); {% endblock js %} From 9dad0975506bcce35b4f46d6128ae10a12c970ac Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 19 Jan 2025 09:19:36 +0200 Subject: [PATCH 11/26] remove char and text --- loco-gen/src/mappings.json | 6 ------ src/schema.rs | 4 ---- 2 files changed, 10 deletions(-) diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index 97888ad83..f1bd05d53 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -435,8 +435,6 @@ "name": "array!", "rust": { "string": "Vec", - "char": "Vec", - "text": "Vec", "float": "Vec", "int": "Vec", "small_int": "Vec", @@ -452,8 +450,6 @@ "name": "array", "rust": { "string": "Option>", - "char": "Option>", - "text": "Option>", "float": "Option>", "int": "Option>", "small_int": "Option>", @@ -469,8 +465,6 @@ "name": "array^", "rust": { "string": "Vec", - "char": "Vec", - "text": "Vec", "float": "Vec", "int": "Vec", "small_int": "Vec", diff --git a/src/schema.rs b/src/schema.rs index cf572ffc4..26d8a8d5b 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -166,8 +166,6 @@ pub enum ColType { pub enum ArrayColType { String, - Text, - Char, Float, Int, SmallInt, @@ -198,8 +196,6 @@ impl ColType { fn array_col_type(kind: &ArrayColType) -> ColumnType { match kind { ArrayColType::String => ColumnType::string(None), - ArrayColType::Text => ColumnType::Text, - ArrayColType::Char => ColumnType::Char(None), ArrayColType::Float => ColumnType::Float, ArrayColType::Int => ColumnType::Integer, ArrayColType::SmallInt => ColumnType::SmallInteger, From a017dd8dd6e3a3bf549e8d281aa4b451f68d9dd7 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Thu, 23 Jan 2025 14:28:25 +0200 Subject: [PATCH 12/26] scaffold improvements --- Cargo.toml | 3 +- loco-gen/Cargo.toml | 4 +- loco-gen/src/lib.rs | 6 + loco-gen/src/mappings.json | 36 +- ..._render_form_field_[form_array!_bool].snap | 14 + ...ender_form_field_[form_array!_double].snap | 32 ++ ...render_form_field_[form_array!_float].snap | 32 ++ ...n_render_form_field_[form_array!_int].snap | 32 ++ ...ender_form_field_[form_array!_string].snap | 32 ++ ..._render_form_field_[form_array^_bool].snap | 14 + ...ender_form_field_[form_array^_double].snap | 32 ++ ...render_form_field_[form_array^_float].snap | 32 ++ ...n_render_form_field_[form_array^_int].snap | 32 ++ ...ender_form_field_[form_array^_string].snap | 32 ++ ...n_render_form_field_[form_array_bool].snap | 14 + ...render_form_field_[form_array_double].snap | 32 ++ ..._render_form_field_[form_array_float].snap | 32 ++ ...an_render_form_field_[form_array_int].snap | 32 ++ ...render_form_field_[form_array_string].snap | 32 ++ ...r_form_field_[form_big_int!_big_int!].snap | 14 + ...r_form_field_[form_big_int^_big_int^].snap | 14 + ...der_form_field_[form_big_int_big_int].snap | 14 + ...ld_[form_big_unsigned!_big_unsigned!].snap | 14 + ...ld_[form_big_unsigned^_big_unsigned^].snap | 14 + ...ield_[form_big_unsigned_big_unsigned].snap | 14 + ..._field_[form_binary_len!_binary_len!].snap | 16 + ..._field_[form_binary_len^_binary_len^].snap | 16 + ...rm_field_[form_binary_len_binary_len].snap | 16 + ..._render_form_field_[form_blob!_blob!].snap | 16 + ...an_render_form_field_[form_blob_blob].snap | 16 + ..._render_form_field_[form_bool!_bool!].snap | 14 + ...an_render_form_field_[form_bool_bool].snap | 14 + ..._render_form_field_[form_date!_date!].snap | 14 + ..._render_form_field_[form_date^_date^].snap | 14 + ...an_render_form_field_[form_date_date].snap | 14 + ...rm_field_[form_date_time!_date_time!].snap | 14 + ...rm_field_[form_date_time^_date_time^].snap | 14 + ...form_field_[form_date_time_date_time].snap | 14 + ...r_form_field_[form_decimal!_decimal!].snap | 14 + ...der_form_field_[form_decimal_decimal].snap | 14 + ...ield_[form_decimal_len!_decimal_len!].snap | 14 + ..._field_[form_decimal_len_decimal_len].snap | 14 + ...der_form_field_[form_double!_double!].snap | 14 + ...ender_form_field_[form_double_double].snap | 14 + ...ender_form_field_[form_float!_float!].snap | 14 + ..._render_form_field_[form_float_float].snap | 14 + ...an_render_form_field_[form_int!_int!].snap | 14 + ...an_render_form_field_[form_int^_int^].snap | 14 + ..._can_render_form_field_[form_int_int].snap | 14 + ..._render_form_field_[form_json!_json!].snap | 14 + ...an_render_form_field_[form_json_json].snap | 14 + ...ender_form_field_[form_jsonb!_jsonb!].snap | 14 + ..._render_form_field_[form_jsonb_jsonb].snap | 14 + ...ender_form_field_[form_money!_money!].snap | 14 + ...ender_form_field_[form_money^_money^].snap | 14 + ..._render_form_field_[form_money_money].snap | 14 + ...rm_field_[form_small_int!_small_int!].snap | 14 + ...rm_field_[form_small_int^_small_int^].snap | 14 + ...form_field_[form_small_int_small_int].snap | 14 + ...form_small_unsigned!_small_unsigned!].snap | 14 + ...form_small_unsigned^_small_unsigned^].snap | 14 + ..._[form_small_unsigned_small_unsigned].snap | 14 + ...der_form_field_[form_string!_string!].snap | 14 + ...der_form_field_[form_string^_string^].snap | 14 + ...ender_form_field_[form_string_string].snap | 14 + ..._render_form_field_[form_text!_text!].snap | 14 + ...an_render_form_field_[form_text_text].snap | 14 + ...form_field_[form_tiny_int!_tiny_int!].snap | 14 + ...form_field_[form_tiny_int^_tiny_int^].snap | 14 + ...r_form_field_[form_tiny_int_tiny_int].snap | 14 + ..._[form_tiny_unsigned!_tiny_unsigned!].snap | 14 + ..._[form_tiny_unsigned^_tiny_unsigned^].snap | 14 + ...ld_[form_tiny_unsigned_tiny_unsigned].snap | 14 + ..._can_render_form_field_[form_ts!_ts!].snap | 14 + ...s__can_render_form_field_[form_ts_ts].snap | 14 + ..._render_form_field_[form_tstz!_tstz!].snap | 14 + ...an_render_form_field_[form_tstz_tstz].snap | 14 + ...form_field_[form_unsigned!_unsigned!].snap | 14 + ...form_field_[form_unsigned^_unsigned^].snap | 14 + ...r_form_field_[form_unsigned_unsigned].snap | 14 + ..._render_form_field_[form_uuid!_uuid!].snap | 16 + ..._render_form_field_[form_uuid^_uuid^].snap | 16 + ...an_render_form_field_[form_uuid_uuid].snap | 16 + ..._field_[form_var_binary!_var_binary!].snap | 16 + ..._field_[form_var_binary^_var_binary^].snap | 16 + ...rm_field_[form_var_binary_var_binary].snap | 16 + ..._field_[form_varbit_len!_varbit_len!].snap | 16 + ..._field_[form_varbit_len^_varbit_len^].snap | 16 + ...rm_field_[form_varbit_len_varbit_len].snap | 16 + loco-gen/src/template_engine.rs | 378 ++++++++++++++++++ loco-gen/src/templates/scaffold/html/base.t | 53 ++- .../src/templates/scaffold/html/controller.t | 3 +- .../src/templates/scaffold/html/view_create.t | 69 +--- .../src/templates/scaffold/html/view_edit.t | 98 +---- .../src/templates/scaffold/html/view_list.t | 76 +++- loco-gen/src/templates/scaffold/htmx/base.t | 94 ++++- .../src/templates/scaffold/htmx/controller.t | 9 +- .../src/templates/scaffold/htmx/view_create.t | 105 +---- .../src/templates/scaffold/htmx/view_edit.t | 141 +------ .../src/templates/scaffold/htmx/view_list.t | 76 +++- .../src/templates/scaffold/htmx/view_show.t | 6 +- loco-new/base_template/Cargo.toml.t | 1 + ..._asset__cargo_dependencies_Clientside.snap | 2 +- ..._asset__cargo_dependencies_Serverside.snap | 2 +- src/cli.rs | 2 +- src/prelude.rs | 2 +- src/schema.rs | 8 +- 107 files changed, 2171 insertions(+), 437 deletions(-) create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap create mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap create mode 100644 loco-gen/src/template_engine.rs diff --git a/Cargo.toml b/Cargo.toml index daffea941..f4fa4c42d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,7 +89,7 @@ axum-extra = { version = "0.10", features = ["cookie"] } regex = { workspace = true } fs-err = "2.11.0" # mailer -tera = "1.19.1" +tera = { workspace = true } thousands = "0.2.0" heck = { workspace = true } cruet = "0.13.0" @@ -160,6 +160,7 @@ bb8 = { version = "0.8.1", optional = true } scraper = { version = "0.21.0", features = ["deterministic"], optional = true } [workspace.dependencies] +tera = { version = "1.19.1" } colored = { version = "2" } chrono = { version = "0.4", features = ["serde"] } tracing = "0.1.40" diff --git a/loco-gen/Cargo.toml b/loco-gen/Cargo.toml index 5edf59e59..8be4da53d 100644 --- a/loco-gen/Cargo.toml +++ b/loco-gen/Cargo.toml @@ -15,7 +15,8 @@ path = "src/lib.rs" [dependencies] cruet = "0.14.0" -rrgen = "0.5.5" +# rrgen = "0.5.5" +rrgen = { git = "https://github.com/jondot/rrgen" } serde = { workspace = true } serde_json = { workspace = true } thiserror = { workspace = true } @@ -24,6 +25,7 @@ tracing = { workspace = true } chrono = { workspace = true } colored = { workspace = true } heck = { workspace = true } +tera = { workspace = true } clap = { version = "4.4.7", features = ["derive"] } duct = "0.13" diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index cf7f9fac0..6c2d2f538 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -24,6 +24,7 @@ mod model; #[cfg(feature = "with-db")] mod scaffold; pub mod template; +mod template_engine; #[cfg(test)] mod testutil; @@ -270,6 +271,11 @@ pub struct AppInfo { pub app_name: String, } +#[must_use] +pub fn new_generator() -> RRgen { + RRgen::default().add_template_engine(template_engine::new()) +} + /// Generate a component /// /// # Errors diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index f1bd05d53..2d438231f 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -1,19 +1,19 @@ { "field_types": [ { - "name": "uuid", + "name": "uuid^", "rust": "Uuid", "schema": "uuid_uniq", "col_type": "UuidUniq" }, { - "name": "uuid_col", + "name": "uuid", "rust": "Option", "schema": "uuid_null", "col_type": "UuidNull" }, { - "name": "uuid_col!", + "name": "uuid!", "rust": "Uuid", "schema": "uuid", "col_type": "Uuid" @@ -286,13 +286,13 @@ }, { "name": "ts", - "rust": "Option", + "rust": "Option", "schema": "timestamp_null", "col_type": "TimestampNull" }, { "name": "ts!", - "rust": "DateTime", + "rust": "DateTimeUtc", "schema": "timestamp", "col_type": "Timestamp" }, @@ -434,13 +434,11 @@ { "name": "array!", "rust": { - "string": "Vec", - "float": "Vec", - "int": "Vec", - "small_int": "Vec", - "big_int": "Vec", - "double": "Vec", - "bool": "Vec" + "string": "Option>", + "float": "Option>", + "int": "Option>", + "double": "Option>", + "bool": "Option>" }, "schema": "array", "col_type": "array", @@ -452,8 +450,6 @@ "string": "Option>", "float": "Option>", "int": "Option>", - "small_int": "Option>", - "big_int": "Option>", "double": "Option>", "bool": "Option>" }, @@ -464,13 +460,11 @@ { "name": "array^", "rust": { - "string": "Vec", - "float": "Vec", - "int": "Vec", - "small_int": "Vec", - "big_int": "Vec", - "double": "Vec", - "bool": "Vec" + "string": "Option>", + "float": "Option>", + "int": "Option>", + "double": "Option>", + "bool": "Option>" }, "schema": "array", "col_type": "array_uniq", diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap new file mode 100644 index 000000000..601c2b010 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap new file mode 100644 index 000000000..f4a8e1f5a --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap new file mode 100644 index 000000000..3960f2a30 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap new file mode 100644 index 000000000..a3ee01d67 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap new file mode 100644 index 000000000..45555fe85 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array! %} + {% for val in item.array! %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap new file mode 100644 index 000000000..bf862b16d --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap new file mode 100644 index 000000000..0ebd54627 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap new file mode 100644 index 000000000..799d2d4b2 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap new file mode 100644 index 000000000..035e81edf --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap new file mode 100644 index 000000000..6fab61748 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array^ %} + {% for val in item.array^ %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap new file mode 100644 index 000000000..2dc195b1c --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap new file mode 100644 index 000000000..a1dc00ceb --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap new file mode 100644 index 000000000..843b98197 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap new file mode 100644 index 000000000..db2cef54b --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap new file mode 100644 index 000000000..5b3f9338d --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap @@ -0,0 +1,32 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
+ Edit Form +
+ + +
+ {% if item.array %} + {% for val in item.array %} + + {% endfor -%} + {%- else -%} + + {%- endif -%} +
+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap new file mode 100644 index 000000000..f465c46a8 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap new file mode 100644 index 000000000..d1772eaa4 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap new file mode 100644 index 000000000..71f6e8c45 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap new file mode 100644 index 000000000..6e7aac022 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap new file mode 100644 index 000000000..54fb669f2 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap new file mode 100644 index 000000000..b0a256582 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap new file mode 100644 index 000000000..a69f639b7 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap new file mode 100644 index 000000000..0177b5ff4 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap new file mode 100644 index 000000000..fe6d30e9e --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap new file mode 100644 index 000000000..b084cfb50 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap new file mode 100644 index 000000000..28f9ed7e1 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap new file mode 100644 index 000000000..4db32abc9 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap new file mode 100644 index 000000000..14499808f --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap new file mode 100644 index 000000000..b6bae2f94 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap new file mode 100644 index 000000000..85b3a3e58 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap new file mode 100644 index 000000000..b91684667 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap new file mode 100644 index 000000000..791ca0651 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap new file mode 100644 index 000000000..b58f56e08 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap new file mode 100644 index 000000000..2c70b2c95 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap new file mode 100644 index 000000000..fbd9b3e91 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap new file mode 100644 index 000000000..211a4b92e --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap new file mode 100644 index 000000000..9167657aa --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap new file mode 100644 index 000000000..9a6780be0 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap new file mode 100644 index 000000000..e06285a83 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap new file mode 100644 index 000000000..a119a204c --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap new file mode 100644 index 000000000..6a54380c5 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap new file mode 100644 index 000000000..bb89b40f7 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap new file mode 100644 index 000000000..0355efab2 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap new file mode 100644 index 000000000..dfa074752 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap new file mode 100644 index 000000000..156f92617 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap new file mode 100644 index 000000000..a2f10db85 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap new file mode 100644 index 000000000..8cc60ccfd --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap new file mode 100644 index 000000000..48d7286da --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap new file mode 100644 index 000000000..bb3fbcbbb --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap new file mode 100644 index 000000000..2e66e3209 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap new file mode 100644 index 000000000..382d495df --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap new file mode 100644 index 000000000..5c0c430d8 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap new file mode 100644 index 000000000..7f7ca2984 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap new file mode 100644 index 000000000..e9157d5b9 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap new file mode 100644 index 000000000..a7bc47687 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap new file mode 100644 index 000000000..93b633178 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap new file mode 100644 index 000000000..9ee0f80e3 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap new file mode 100644 index 000000000..ff730e156 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap new file mode 100644 index 000000000..4e20b9d85 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap new file mode 100644 index 000000000..538a3c4c5 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap new file mode 100644 index 000000000..8c7d67b4b --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap new file mode 100644 index 000000000..5b350073c --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap new file mode 100644 index 000000000..bd99b20a0 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap new file mode 100644 index 000000000..903b3215e --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap new file mode 100644 index 000000000..f602ac229 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap new file mode 100644 index 000000000..d29f29ff5 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap new file mode 100644 index 000000000..75df99639 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap new file mode 100644 index 000000000..0670d9c05 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap new file mode 100644 index 000000000..b9d86123f --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap new file mode 100644 index 000000000..807aa2839 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap new file mode 100644 index 000000000..7d09d3f63 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap new file mode 100644 index 000000000..56a977523 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap new file mode 100644 index 000000000..6c0b67024 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap new file mode 100644 index 000000000..ae206e234 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap new file mode 100644 index 000000000..7a5022a3e --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap new file mode 100644 index 000000000..43add08df --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap new file mode 100644 index 000000000..7231cd3e5 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 11111111-1111-1111-1111-111111111111..

+
+ Edit Form +
+ + +

e.g: 11111111-1111-1111-1111-111111111111..

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap new file mode 100644 index 000000000..95fc4cb0a --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 11111111-1111-1111-1111-111111111111..

+
+ Edit Form +
+ + +

e.g: 11111111-1111-1111-1111-111111111111..

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap new file mode 100644 index 000000000..8eefd95b8 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 11111111-1111-1111-1111-111111111111..

+
+ Edit Form +
+ + +

e.g: 11111111-1111-1111-1111-111111111111..

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap new file mode 100644 index 000000000..6a819f464 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap new file mode 100644 index 000000000..6dad69da3 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap new file mode 100644 index 000000000..727659562 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap new file mode 100644 index 000000000..b6a429e8e --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap new file mode 100644 index 000000000..e14a1dae5 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap new file mode 100644 index 000000000..3bc9ddb6a --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/template_engine.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/template_engine.rs b/loco-gen/src/template_engine.rs new file mode 100644 index 000000000..113a212f3 --- /dev/null +++ b/loco-gen/src/template_engine.rs @@ -0,0 +1,378 @@ +use std::collections::HashMap; + +use tera::{Tera, Value}; + +pub fn new() -> Tera { + let mut tera = Tera::default(); + tera.register_function("render_form_field", FormField); + tera +} + +const DEFAULT_INPUT_CLASS: &str = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-base shadow-sm md:text-sm"; +struct FormField; + +impl tera::Function for FormField { + #[allow(clippy::too_many_lines)] + fn call(&self, args: &HashMap) -> tera::Result { + let fname = args + .get("fname") + .ok_or_else(|| tera::Error::msg("fname is mandatory"))? + .as_str() + .ok_or_else(|| tera::Error::msg("fname must be a string"))?; + let ftype = args + .get("ftype") + .ok_or_else(|| tera::Error::msg("ftype is mandatory"))? + .as_str() + .ok_or_else(|| tera::Error::msg("ftype must be a string"))?; + let rust_type = args + .get("rust_type") + .ok_or_else(|| tera::Error::msg("rust_type is mandatory"))? + .as_str() + .ok_or_else(|| tera::Error::msg("rust_type must be a string"))?; + + let is_edit_form = args + .get("edit_form") + .unwrap_or(&Value::Bool(false)) + .as_bool() + .unwrap_or_default(); + + let value = if is_edit_form { + format!("{{{{item.{fname}}}}}") + } else { + String::new() + }; + + let input_class = args + .get("input_class") + .and_then(|c| c.as_str()) + .unwrap_or(DEFAULT_INPUT_CLASS); + + let is_required = ftype.ends_with('!') || ftype.ends_with('^'); + let required_value = if is_required { "required" } else { "" }; + + let element = match rust_type { + "Uuid" | "Option" => { + let desc = input_description("e.g: 11111111-1111-1111-1111-111111111111."); + let input = input_string( + fname, + &value, + is_required, + input_class, + Some( + r#"pattern="[0-9A-Fa-f]{{8}}-[0-9A-Fa-f]{{4}}-[0-9A-Fa-f]{{4}}-[0-9A-Fa-f]{{4}}-[0-9A-Fa-f]{{12}}""#, + ), + ); + format!( + r"{input} + {desc}", + ) + } + "serde_json::Value" | "Option" => { + format!( + r#""#, + ) + } + "String" | "Option" => { + input_string(fname, &value, is_required, input_class, None) + } + + "i8" | "Option" => input_number( + fname, + &value, + is_required, + input_class, + Some((i8::MIN, i8::MAX)), + Some(r#"step="1""#), + ), + "i16" | "Option" => input_number( + fname, + &value, + is_required, + input_class, + Some((i16::MIN, i16::MAX)), + Some(r#"step="1""#), + ), + "i32" | "Option" => input_number( + fname, + &value, + is_required, + input_class, + Some((i32::MIN, i32::MAX)), + Some(r#"step="1""#), + ), + "i64" | "Option" => input_number( + fname, + &value, + is_required, + input_class, + Some((i64::MIN, i64::MAX)), + Some(r#"step="1""#), + ), + "Decimal" | "Option" => input_number::( + fname, + &value, + is_required, + input_class, + Some(( + -79_228_162_514_264_337_593_543_950_335, + 79_228_162_514_264_337_593_543_950_335, + )), + Some(r#"step="0.1""#), + ), + "f32" | "Option" => input_number( + fname, + &value, + is_required, + input_class, + Some((f32::MIN, f32::MAX)), + Some(r#"step="0.1""#), + ), + "f64" | "Option" => input_number( + fname, + &value, + is_required, + input_class, + Some((f64::MIN, f64::MAX)), + Some(r#"step="0.1""#), + ), + "DateTimeWithTimeZone" + | "Option" + | "DateTime" + | "Option" + | "DateTimeUtc" + | "Option" => { + format!( + r#""#, + ) + } + "Date" | "Option" => { + format!( + r#""#, + ) + } + "bool" | "Option" => { + let checked = if is_edit_form { + format!("{{% if item.{fname} %}}checked{{%endif %}}") + } else { + String::new() + }; + format!( + r#""#, + ) + } + "Vec" | "Option>" => { + format!( + r#" +

e.g: 123,123,123 .

"#, + ) + } + "Vec" | "Option>" => { + format!( + r#" +
+ {{% if item.{fname} %}} + {{% for val in item.{fname} %}} + + {{% endfor -%}} + {{%- else -%}} + + {{%- endif -%}} +
"# + ) + } + "Vec" | "Option>" => { + let edit_input = input_number( + fname, + "{{val}}", + is_required, + input_class, + Some((f32::MIN, f32::MAX)), + Some(r#"custom_type="array" step="0.1""#), + ); + let create_input = input_number( + fname, + &value, + is_required, + input_class, + Some((f32::MIN, f32::MAX)), + Some(r#"custom_type="array" step="0.1""#), + ); + input_group(fname, &create_input, &edit_input) + } + "Vec" | "Option>" => { + let edit_input = input_number( + fname, + "{{val}}", + is_required, + input_class, + Some((f64::MIN, f64::MAX)), + Some(r#"custom_type="array""#), + ); + let create_input = input_number( + fname, + &value, + is_required, + input_class, + Some((f64::MIN, f64::MAX)), + Some(r#"custom_type="array""#), + ); + input_group(fname, &create_input, &edit_input) + } + "Vec" | "Option>" => { + let edit_input = input_number( + fname, + "{{val}}", + is_required, + input_class, + Some((i32::MIN, i32::MAX)), + Some(r#"custom_type="array""#), + ); + let create_input = input_number( + fname, + &value, + is_required, + input_class, + Some((i32::MIN, i32::MAX)), + Some(r#"custom_type="array""#), + ); + input_group(fname, &create_input, &edit_input) + } + "Vec" | "Option>" => String::new(), + _ => { + return Err(tera::Error::msg(format!( + "rust_type: `{rust_type}` not implemented" + ))) + } + }; + + Ok(Value::String(format!( + r#"
+ + {element} +
"# + ))) + } + + fn is_safe(&self) -> bool { + true + } +} + +fn input_group(fname: &str, create_input: &str, edit_input: &str) -> String { + format!( + r#" +
+ {{% if item.{fname} %}} + {{% for val in item.{fname} %}} + {edit_input} + {{% endfor -%}} + {{%- else -%}} + {create_input} + {{%- endif -%}} +
"# + ) +} + +fn input_string( + name: &str, + value: &str, + is_required: bool, + class: &str, + attr: Option<&str>, +) -> String { + let attr = attr.unwrap_or_default(); + println!("is_required: {is_required}"); + let required_value = if is_required { "required" } else { "" }; + format!( + r#""# + ) +} + +fn input_number( + name: &str, + value: &str, + is_required: bool, + class: &str, + range: Option<(T, T)>, + attr: Option<&str>, +) -> String +where + T: PartialOrd + std::fmt::Display, +{ + let required_value = if is_required { "required" } else { "" }; + + let (min_attr, max_attr) = if let Some((min, max)) = range { + (format!(r#"min="{min}""#), format!(r#"max="{max}""#)) + } else { + (String::new(), String::new()) + }; + + let attr = attr.unwrap_or_default(); + format!( + r#""#, + ) +} + +fn input_description>(description: S) -> String { + format!( + r#"

{}.

"#, + description.as_ref() + ) +} + +#[cfg(test)] +pub mod tests { + use super::*; + + use crate::get_mappings; + use insta::assert_snapshot; + + #[test] + fn can_render_form_field() { + let mapping = get_mappings(); + + let mut template_engine = new(); + + template_engine + .add_raw_template( + "template", + r"{{ render_form_field(fname=fname_val, ftype=ftype_val, rust_type=rust_type_val, edit_form=edit_form_val)}}" + ) + .unwrap_or_else(|_| panic!("Failed to add raw template")); + + for field in &mapping.field_types { + let rust_fields = match &field.rust { + crate::RustType::String(rust_field) => { + HashMap::from([(field.name.to_string(), rust_field.to_string())]) + } + crate::RustType::Map(data) => data.clone(), + }; + + for (field_name, rust_field_type) in rust_fields { + let mut template_ctx = tera::Context::new(); + template_ctx.insert("fname_val", &field.name); + template_ctx.insert("ftype_val", &field.name); + template_ctx.insert("rust_type_val", &rust_field_type); + template_ctx.insert("edit_form_val", &false); + + let create_form = template_engine + .render("template", &template_ctx) + .unwrap_or_else(|err| { + panic!("Failed to render template. context: {template_ctx:?} .err: {err:?}") + }); + + template_ctx.insert("edit_form_val", &true); + let edit_form = template_engine + .render("template", &template_ctx) + .unwrap_or_else(|err| { + panic!("Failed to render template. context: {template_ctx:?} .err: {err:?}") + }); + + assert_snapshot!( + format!("can_render_form_field_[form_{}_{}]", field.name, field_name), + format!("Crete form\n\r{create_form}\n\rEdit Form\n\r{edit_form}") + ); + } + } + } +} diff --git a/loco-gen/src/templates/scaffold/html/base.t b/loco-gen/src/templates/scaffold/html/base.t index af33dc648..f5461cb9d 100644 --- a/loco-gen/src/templates/scaffold/html/base.t +++ b/loco-gen/src/templates/scaffold/html/base.t @@ -16,15 +16,56 @@ message: "Base template was added successfully." {% raw %}{% endblock head %}{% endraw %} - -
- {% raw %}{% block content %} - {% endblock content %}{% endraw %} -
- + +
+
+
+
+
+

+ {% raw %}{% block page_title %}{% endblock page_title %}{% endraw %} +

+ {% raw %}{% block content %} + {% endblock content %}{% endraw %} +
+
+
+
+
{% raw %}{% block js %} {% endblock js %}{% endraw %} + + \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/html/controller.t b/loco-gen/src/templates/scaffold/html/controller.t index f12201ecd..44179387f 100644 --- a/loco-gen/src/templates/scaffold/html/controller.t +++ b/loco-gen/src/templates/scaffold/html/controller.t @@ -16,7 +16,8 @@ injections: #![allow(clippy::unused_async)] use loco_rs::prelude::*; use serde::{Deserialize, Serialize}; -use axum::{extract::Form, response::Redirect}; +use axum::response::Redirect; +use axum_extra::extract::Form; use sea_orm::{sea_query::Order, QueryOrder}; use axum::debug_handler; diff --git a/loco-gen/src/templates/scaffold/html/view_create.t b/loco-gen/src/templates/scaffold/html/view_create.t index c9bb56b9e..8f7502649 100644 --- a/loco-gen/src/templates/scaffold/html/view_create.t +++ b/loco-gen/src/templates/scaffold/html/view_create.t @@ -10,54 +10,17 @@ message: "{{file_name}} create view was added successfully." Create {{file_name}} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +Create new {{name}} +{% raw %}{% endblock page_title %}{% endraw %} + {% raw %}{% block content %}{% endraw %} -

Create new {{file_name}}

-
-
- {% for column in columns -%} -
- -
- {% if column.2 == "text" -%} - - {% elif column.2 == "string" -%} - - {% elif column.2 == "string!" or column.2 == "string^" -%} - - {% elif column.2 == "int" or column.2 == "int!" or column.2 == "int^"-%} - - {% elif column.2 == "bool"-%} - - {% elif column.2 == "bool!"-%} - - {% elif column.2 == "ts"-%} - - {% elif column.2 == "ts!"-%} - - {% elif column.2 == "uuid"-%} - - {% elif column.2 == "uuid!"-%} - - {% elif column.2 == "json" or column.2 == "jsonb" -%} - - {% elif column.2 == "json!" or column.2 == "jsonb!" -%} - - {% elif column.2 == "array!" or column.2 == "array^" -%} -
- -
- - {% elif column.2 == "array" -%} -
- -
- - {% endif -%} -
+ + {% for column in columns -%} + {{ render_form_field(fname=column.0, rust_type=column.1, ftype=column.2)}} {% endfor -%} -
-
+
@@ -67,19 +30,5 @@ Create {{file_name}} {% raw %}{% endblock content %}{% endraw %} {% raw %}{% block js %}{% endraw %} - + {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/html/view_edit.t b/loco-gen/src/templates/scaffold/html/view_edit.t index dbd7725fd..6ace7b4ef 100644 --- a/loco-gen/src/templates/scaffold/html/view_edit.t +++ b/loco-gen/src/templates/scaffold/html/view_edit.t @@ -10,98 +10,30 @@ message: "{{file_name}} edit view was added successfully." Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} +{% raw %}{% endblock page_title %}{% endraw %} + {% raw %}{% block content %}{% endraw %} -

Edit {{name}}: {% raw %}{{ item.id }}{% endraw %}

-
-
+ {% for column in columns -%} + {{ render_form_field(fname=column.0, rust_type=column.1, ftype=column.2, edit_form=true)}} + {% endfor -%}
- -
- {% if column.2 == "text" -%} - - {% elif column.2 == "string" -%} - - {% elif column.2 == "string!" or column.2 == "string^" -%} - - {% elif column.2 == "int" or column.2 == "int!" or column.2 == "int^"-%} - - {% elif column.2 == "bool"-%} - - {% elif column.2 == "bool!"-%} - - {% elif column.2 == "ts"-%} - - {% elif column.2 == "ts!"-%} - - {% elif column.2 == "uuid"-%} - - {% elif column.2 == "uuid!"-%} - - {% elif column.2 == "json" or column.2 == "jsonb" -%} - - {% elif column.2 == "json!" or column.2 == "jsonb!" -%} - - {% elif column.2 == "array!" or column.2 == "array^" -%} -
- {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} - - {% raw %}{% endfor -%}{% endraw %} +
+ +
- - {% elif column.2 == "array" -%} -
- {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} - - {% raw %}{% endfor -%}{% endraw %} -
- - {% endif -%} -
- -
- {% endfor -%} -
-
- - -
+
-
-Back to {{name | plural}} +
+
+ Back to {{name}}
{% raw %}{% endblock content %}{% endraw %} {% raw %}{% block js %}{% endraw %} - {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/html/view_list.t b/loco-gen/src/templates/scaffold/html/view_list.t index 23fae2345..7c4eb48c4 100644 --- a/loco-gen/src/templates/scaffold/html/view_list.t +++ b/loco-gen/src/templates/scaffold/html/view_list.t @@ -10,23 +10,73 @@ message: "{{file_name}} list view was added successfully." List of {{file_name}} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +{{file_name}} +{% raw %}{% endblock page_title %}{% endraw %} + {% raw %}{% block content %}{% endraw %} -

{{file_name}}s

-{% raw %}{% for item in items %}{% endraw %} + + {% raw %}{% if items %}{% endraw %} +
- {% for column in columns -%} -
- - +
+ + + + {% for column in columns -%} + + {% endfor -%} + + + + + {% raw %}{% for item in items %}{% endraw %} + + {% for column in columns -%} + + {% endfor -%} + + + {% raw %}{% endfor %}{% endraw %} + +
+ {% raw %}{{"{% endraw %}{{column.0}}{% raw %}" | capitalize }}{% endraw %} + + Actions +
+ {% raw %}{{item.{% endraw %}{{column.0}}{% raw %}}}{% endraw %} + + Edit +
+
+ +
+ - {% endfor -%} - Edit - View +
-{% raw %}{% endfor %}{% endraw %} -
-
-New {{name}} + + {% raw %}{% else %}{% endraw %} + +
+
+

Nothing Here Yet

+ There are no records to display. Add a new record to get started! + + Create + +
+
+ + {% raw %}{% endif %}{% endraw %} + +
{% raw %}{% endblock content %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/htmx/base.t b/loco-gen/src/templates/scaffold/htmx/base.t index e360b023b..4651c3e13 100644 --- a/loco-gen/src/templates/scaffold/htmx/base.t +++ b/loco-gen/src/templates/scaffold/htmx/base.t @@ -18,15 +18,99 @@ message: "Base template was added successfully." {% raw %}{% endblock head %}{% endraw %} - -
- {% raw %}{% block content %} - {% endblock content %}{% endraw %} -
+ +
+
+
+
+
+

+ {% raw %}{% block page_title %}{% endblock page_title %}{% endraw %} +

+ {% raw %}{% block content %} + {% endblock content %}{% endraw %} +
+
+
+ +
+
{% raw %}{% block js %} {% endblock js %}{% endraw %} + + \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/htmx/controller.t b/loco-gen/src/templates/scaffold/htmx/controller.t index 0a47346a9..e881b0699 100644 --- a/loco-gen/src/templates/scaffold/htmx/controller.t +++ b/loco-gen/src/templates/scaffold/htmx/controller.t @@ -73,8 +73,8 @@ pub async fn update( let item = load_item(&ctx, id).await?; let mut item = item.into_active_model(); params.update(&mut item); - let item = item.update(&ctx.db).await?; - format::json(item) + let _ = item.update(&ctx.db).await?; + format::render().redirect_with_header_key("HX-Redirect", "/{{name | plural}}") } #[debug_handler] @@ -99,7 +99,6 @@ pub async fn show( #[debug_handler] pub async fn add( - ViewEngine(v): ViewEngine, State(ctx): State, Json(params): Json, ) -> Result { @@ -107,8 +106,8 @@ pub async fn add( ..Default::default() }; params.update(&mut item); - let item = item.insert(&ctx.db).await?; - views::{{file_name}}::show(&v, &item) + let _ = item.insert(&ctx.db).await?; + format::render().redirect_with_header_key("HX-Redirect", "/{{name | plural}}") } #[debug_handler] diff --git a/loco-gen/src/templates/scaffold/htmx/view_create.t b/loco-gen/src/templates/scaffold/htmx/view_create.t index 3fbdb1978..106e44942 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_create.t +++ b/loco-gen/src/templates/scaffold/htmx/view_create.t @@ -10,108 +10,25 @@ message: "{{file_name}} create view was added successfully." Create {{file_name}} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +Create new {{name}} +{% raw %}{% endblock page_title %}{% endraw %} + {% raw %}{% block content %}{% endraw %}
-
-

Create new {{name}}

-
+
+ {% for column in columns -%} -
- -
- {% if column.2 == "text" -%} - - {% elif column.2 == "string" -%} - - {% elif column.2 == "string!" or column.2 == "string^" -%} - - {% elif column.2 == "int" or column.2 == "int!" or column.2 == "int^"-%} - - {% elif column.2 == "bool"-%} - - {% elif column.2 == "bool!"-%} - - {% elif column.2 == "ts"-%} - - {% elif column.2 == "ts!"-%} - - {% elif column.2 == "uuid"-%} - - {% elif column.2 == "uuid!"-%} - - {% elif column.2 == "json" or column.2 == "jsonb" -%} - - {% elif column.2 == "json!" or column.2 == "jsonb!" -%} - - {% elif column.2 == "array!" or column.2 == "array^" -%} -
- -
- - {% elif column.2 == "array" -%} -
- -
- - {% endif -%} + {{ render_form_field(fname=column.0, rust_type=column.1, ftype=column.2)}} + {% endfor -%} +
+
- {% endfor -%} -
-
- -
+
{% raw %}{% endblock content %}{% endraw %} {% raw %}{% block js %}{% endraw %} - {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/htmx/view_edit.t b/loco-gen/src/templates/scaffold/htmx/view_edit.t index 58f97ef35..c768442c1 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_edit.t +++ b/loco-gen/src/templates/scaffold/htmx/view_edit.t @@ -10,136 +10,31 @@ message: "{{file_name}} edit view was added successfully." Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +Edit {{name}}: {% raw %}{{ item.id }}{% endraw %} +{% raw %}{% endblock page_title %}{% endraw %} + {% raw %}{% block content %}{% endraw %} -

Edit {{name}}: {% raw %}{{ item.id }}{% endraw %}

-
-
- {% for column in columns -%} +
+ + {% for column in columns -%} + {{ render_form_field(fname=column.0, rust_type=column.1, ftype=column.2, edit_form=true)}} + {% endfor -%}
- -
- {% if column.2 == "text" -%} - - {% elif column.2 == "string" -%} - - {% elif column.2 == "string!" or column.2 == "string^" -%} - - {% elif column.2 == "int" or column.2 == "int!" or column.2 == "int^"-%} - - {% elif column.2 == "bool"-%} - - {% elif column.2 == "bool!"-%} - - {% elif column.2 == "ts"-%} - - {% elif column.2 == "ts!"-%} - - {% elif column.2 == "uuid"-%} - - {% elif column.2 == "uuid!"-%} - - {% elif column.2 == "json" or column.2 == "jsonb" -%} - - {% elif column.2 == "json!" or column.2 == "jsonb!" -%} - - {% elif column.2 == "array!" or column.2 == "array^" -%} -
- {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} - - {% raw %}{% endfor -%}{% endraw %} -
- - {% elif column.2 == "array" -%} -
- {% raw %}{%{% endraw %} for data in item.{{column.0}} {% raw %}-%}{% endraw %} - - {% raw %}{% endfor -%}{% endraw %} -
- - {% endif -%} -
- {% endfor -%} -
-
-
- - +
+ + +
-
-
-
-
-Back to {{name}} + +
+
+ Back to {{name}}
{% raw %}{% endblock content %}{% endraw %} {% raw %}{% block js %}{% endraw %} - {% raw %}{% endblock js %}{% endraw %} \ No newline at end of file diff --git a/loco-gen/src/templates/scaffold/htmx/view_list.t b/loco-gen/src/templates/scaffold/htmx/view_list.t index 739a5b40a..2ad4ac6e5 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_list.t +++ b/loco-gen/src/templates/scaffold/htmx/view_list.t @@ -10,23 +10,73 @@ message: "{{file_name}} list view was added successfully." List of {{file_name}} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +{{file_name}} +{% raw %}{% endblock page_title %}{% endraw %} + {% raw %}{% block content %}{% endraw %} -

{{file_name}}

- {% raw %}{% for item in items %}{% endraw %} + + {% raw %}{% if items %}{% endraw %} +
- {% for column in columns -%} -
- -
- {% endfor -%} - Edit - View +
+ + + + {% for column in columns -%} + + {% endfor -%} + + + + + {% raw %}{% for item in items %}{% endraw %} + + {% for column in columns -%} + + {% endfor -%} + + + {% raw %}{% endfor %}{% endraw %} + +
+ {% raw %}{{"{% endraw %}{{column.0}}{% raw %}" | capitalize }}{% endraw %} + + Actions +
+ {% raw %}{{item.{% endraw %}{{column.0}}{% raw %}}}{% endraw %} + + Edit +
+
+ +
+ +
+
+ + {% raw %}{% else %}{% endraw %} + +
+
+

Nothing Here Yet

+ There are no records to display. Add a new record to get started! + + Create +
- {% raw %}{% endfor %}{% endraw %} +
+ + {% raw %}{% endif %}{% endraw %} -
-
- New {{name}} +
{% raw %}{% endblock content %}{% endraw %} diff --git a/loco-gen/src/templates/scaffold/htmx/view_show.t b/loco-gen/src/templates/scaffold/htmx/view_show.t index 3c888247d..c11a234c8 100644 --- a/loco-gen/src/templates/scaffold/htmx/view_show.t +++ b/loco-gen/src/templates/scaffold/htmx/view_show.t @@ -10,8 +10,12 @@ message: "{{file_name}} view was added successfully." View {{name}}: {% raw %}{{ item.id }}{% endraw %} {% raw %}{% endblock title %}{% endraw %} +{% raw %}{% block page_title %}{% endraw %} +View {{name}}: {% raw %}{{ item.id }}{% endraw %} +{% raw %}{% endblock page_title %}{% endraw %} + + {% raw %}{% block content %}{% endraw %} -

View {{name}}: {% raw %}{{ item.id }}{% endraw %}

{% for column in columns -%}
diff --git a/loco-new/base_template/Cargo.toml.t b/loco-new/base_template/Cargo.toml.t index 4c1044c9a..cc219718c 100644 --- a/loco-new/base_template/Cargo.toml.t +++ b/loco-new/base_template/Cargo.toml.t @@ -52,6 +52,7 @@ include_dir = { version = "0.7" } fluent-templates = { version = "0.8.0", features = ["tera"] } unic-langid = { version = "0.9.4" } # /view engine +axum-extra = { version = "0.10", features = ["form"] } {%- endif %} [[bin]] diff --git a/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Clientside.snap b/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Clientside.snap index 0b77f22a9..a75738380 100644 --- a/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Clientside.snap +++ b/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Clientside.snap @@ -2,4 +2,4 @@ source: tests/templates/asset.rs expression: "content.get(\"dependencies\").unwrap()" --- -{ async-trait = { version = "0.1.74" }, axum = { version = "0.8.1" }, fluent-templates = { features = ["tera"], version = "0.8.0" }, loco-rs = { workspace = true }, regex = { version = "1.11.1" }, serde = { features = ["derive"], version = "1" }, serde_json = { version = "1" }, tokio = { default-features = false, features = ["rt-multi-thread"], version = "1.33.0" }, tracing = { version = "0.1.40" }, tracing-subscriber = { features = ["env-filter", "json"], version = "0.3.17" }, unic-langid = { version = "0.9.4" } } +{ async-trait = { version = "0.1.74" }, axum = { version = "0.8.1" }, axum-extra = { features = ["form"], version = "0.10" }, fluent-templates = { features = ["tera"], version = "0.8.0" }, loco-rs = { workspace = true }, regex = { version = "1.11.1" }, serde = { features = ["derive"], version = "1" }, serde_json = { version = "1" }, tokio = { default-features = false, features = ["rt-multi-thread"], version = "1.33.0" }, tracing = { version = "0.1.40" }, tracing-subscriber = { features = ["env-filter", "json"], version = "0.3.17" }, unic-langid = { version = "0.9.4" } } diff --git a/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Serverside.snap b/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Serverside.snap index 0b77f22a9..a75738380 100644 --- a/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Serverside.snap +++ b/loco-new/tests/templates/snapshots/r#mod__templates__asset__cargo_dependencies_Serverside.snap @@ -2,4 +2,4 @@ source: tests/templates/asset.rs expression: "content.get(\"dependencies\").unwrap()" --- -{ async-trait = { version = "0.1.74" }, axum = { version = "0.8.1" }, fluent-templates = { features = ["tera"], version = "0.8.0" }, loco-rs = { workspace = true }, regex = { version = "1.11.1" }, serde = { features = ["derive"], version = "1" }, serde_json = { version = "1" }, tokio = { default-features = false, features = ["rt-multi-thread"], version = "1.33.0" }, tracing = { version = "0.1.40" }, tracing-subscriber = { features = ["env-filter", "json"], version = "0.3.17" }, unic-langid = { version = "0.9.4" } } +{ async-trait = { version = "0.1.74" }, axum = { version = "0.8.1" }, axum-extra = { features = ["form"], version = "0.10" }, fluent-templates = { features = ["tera"], version = "0.8.0" }, loco-rs = { workspace = true }, regex = { version = "1.11.1" }, serde = { features = ["derive"], version = "1" }, serde_json = { version = "1" }, tokio = { default-features = false, features = ["rt-multi-thread"], version = "1.33.0" }, tracing = { version = "0.1.40" }, tracing-subscriber = { features = ["env-filter", "json"], version = "0.3.17" }, unic-langid = { version = "0.9.4" } } diff --git a/src/cli.rs b/src/cli.rs index 63b68a755..add6b6a8e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1085,7 +1085,7 @@ fn handle_generate_command( } } else { let get_result = loco_gen::generate( - &loco_gen::RRgen::default(), + &loco_gen::new_generator(), component.into_gen_component(config)?, &loco_gen::AppInfo { app_name: H::app_name().to_string(), diff --git a/src/prelude.rs b/src/prelude.rs index 46c341919..99e280b50 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -9,7 +9,7 @@ pub use chrono::NaiveDateTime as DateTime; pub use include_dir::{include_dir, Dir}; // some types required for controller generators #[cfg(feature = "with-db")] -pub use sea_orm::prelude::{Date, DateTimeWithTimeZone, Decimal, Uuid}; +pub use sea_orm::prelude::{Date, DateTimeUtc, DateTimeWithTimeZone, Decimal, Uuid}; #[cfg(feature = "with-db")] pub use sea_orm::{ ActiveModelBehavior, ActiveModelTrait, ActiveValue, ColumnTrait, ConnectionTrait, diff --git a/src/schema.rs b/src/schema.rs index 26d8a8d5b..b5d4b4e0a 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -168,10 +168,8 @@ pub enum ArrayColType { String, Float, Int, - SmallInt, - BigInt, Double, - Boolean, + Bool, } impl ColType { @@ -198,10 +196,8 @@ impl ColType { ArrayColType::String => ColumnType::string(None), ArrayColType::Float => ColumnType::Float, ArrayColType::Int => ColumnType::Integer, - ArrayColType::SmallInt => ColumnType::SmallInteger, - ArrayColType::BigInt => ColumnType::BigInteger, ArrayColType::Double => ColumnType::Double, - ArrayColType::Boolean => ColumnType::Boolean, + ArrayColType::Bool => ColumnType::Boolean, } } } From 41a834ad2fdd1b64830b3d68b06a238a7fc73d1c Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Thu, 23 Jan 2025 14:57:51 +0200 Subject: [PATCH 13/26] scaffold improvements --- .github/workflows/loco-gen-e2e.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/loco-gen-e2e.yml b/.github/workflows/loco-gen-e2e.yml index 223b784ab..91eb1e4d4 100644 --- a/.github/workflows/loco-gen-e2e.yml +++ b/.github/workflows/loco-gen-e2e.yml @@ -167,8 +167,8 @@ jobs: run: | cargo run -- generate model post \ uuid_uniq:uuid \ - uuid_null:uuid_col \ - uuid:uuid_col! \ + uuid_null:uuid \ + uuid:uuid! \ string_null:string \ string:string! \ string_uniq:string^ \ From 3779387ab1bd24306f28ed493d8f4065296497e8 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Thu, 23 Jan 2025 15:35:27 +0200 Subject: [PATCH 14/26] more snap --- loco-gen/src/lib.rs | 2 +- loco-gen/tests/templates/scaffold.rs | 4 +- ...nerate[controller_file]@Html_scaffold.snap | 3 +- ...nerate[controller_file]@Htmx_scaffold.snap | 9 +- ...enerate[views_[create]]@Html_scaffold.snap | 36 ++----- ...enerate[views_[create]]@Htmx_scaffold.snap | 72 +++---------- .../generate[views_[edit]]@Html_scaffold.snap | 63 ++++------- .../generate[views_[edit]]@Htmx_scaffold.snap | 102 ++++-------------- .../generate[views_[list]]@Html_scaffold.snap | 70 ++++++++++-- .../generate[views_[list]]@Htmx_scaffold.snap | 70 ++++++++++-- .../generate[views_[show]]@Htmx_scaffold.snap | 6 +- 11 files changed, 194 insertions(+), 243 deletions(-) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 6c2d2f538..0390143d6 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -24,7 +24,7 @@ mod model; #[cfg(feature = "with-db")] mod scaffold; pub mod template; -mod template_engine; +pub mod template_engine; #[cfg(test)] mod testutil; diff --git a/loco-gen/tests/templates/scaffold.rs b/loco-gen/tests/templates/scaffold.rs index b713b9c75..af9221fd3 100644 --- a/loco-gen/tests/templates/scaffold.rs +++ b/loco-gen/tests/templates/scaffold.rs @@ -1,6 +1,6 @@ use super::utils::{guess_file_by_time, APP_ROUTS, MIGRATION_SRC_LIB}; use insta::{assert_snapshot, with_settings}; -use loco_gen::{collect_messages, generate, AppInfo, Component, ScaffoldKind}; +use loco_gen::{collect_messages, generate, template_engine, AppInfo, Component, ScaffoldKind}; use rrgen::RRgen; use rstest::rstest; use std::fs; @@ -37,7 +37,7 @@ fn can_generate(#[case] kind: ScaffoldKind) { .create() .unwrap(); - let rrgen = RRgen::with_working_dir(&tree_fs.root); + let rrgen = RRgen::with_working_dir(&tree_fs.root).add_template_engine(template_engine::new()); let gen_result = generate( &rrgen, diff --git a/loco-gen/tests/templates/snapshots/generate[controller_file]@Html_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[controller_file]@Html_scaffold.snap index 2cfd0f14e..d02650ed5 100644 --- a/loco-gen/tests/templates/snapshots/generate[controller_file]@Html_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[controller_file]@Html_scaffold.snap @@ -7,7 +7,8 @@ expression: "fs::read_to_string(controllers_path.join(\"movie.rs\")).expect(\"co #![allow(clippy::unused_async)] use loco_rs::prelude::*; use serde::{Deserialize, Serialize}; -use axum::{extract::Form, response::Redirect}; +use axum::response::Redirect; +use axum_extra::extract::Form; use sea_orm::{sea_query::Order, QueryOrder}; use axum::debug_handler; diff --git a/loco-gen/tests/templates/snapshots/generate[controller_file]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[controller_file]@Htmx_scaffold.snap index 2ee89c16e..73333e689 100644 --- a/loco-gen/tests/templates/snapshots/generate[controller_file]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[controller_file]@Htmx_scaffold.snap @@ -60,8 +60,8 @@ pub async fn update( let item = load_item(&ctx, id).await?; let mut item = item.into_active_model(); params.update(&mut item); - let item = item.update(&ctx.db).await?; - format::json(item) + let _ = item.update(&ctx.db).await?; + format::render().redirect_with_header_key("HX-Redirect", "/movies") } #[debug_handler] @@ -86,7 +86,6 @@ pub async fn show( #[debug_handler] pub async fn add( - ViewEngine(v): ViewEngine, State(ctx): State, Json(params): Json, ) -> Result { @@ -94,8 +93,8 @@ pub async fn add( ..Default::default() }; params.update(&mut item); - let item = item.insert(&ctx.db).await?; - views::movie::show(&v, &item) + let _ = item.insert(&ctx.db).await?; + format::render().redirect_with_header_key("HX-Redirect", "/movies") } #[debug_handler] diff --git a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap index cb61380dd..93596d8f3 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Html_scaffold.snap @@ -8,18 +8,18 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec Create movie {% endblock title %} +{% block page_title %} +Create new movie +{% endblock page_title %} + {% block content %} -

Create new movie

-
-
-
- -
- -
-
-
+ +
+ + +
+
@@ -29,19 +29,5 @@ Create movie {% endblock content %} {% block js %} - + {% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap index 384b96012..091465c86 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[create]]@Htmx_scaffold.snap @@ -8,72 +8,26 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec Create movie {% endblock title %} +{% block page_title %} +Create new movie +{% endblock page_title %} + {% block content %}
-
-

Create new movie

-
-
- -
- +
+ +
+ + +
+
+
-
-
- -
+
{% endblock content %} {% block js %} - {% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap index 86f992247..d71edbcef 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Html_scaffold.snap @@ -8,58 +8,31 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec Edit movie: {{ item.id }} {% endblock title %} +{% block page_title %} +Edit movie: {{ item.id }} +{% endblock page_title %} + {% block content %} -

Edit movie: {{ item.id }}

-
-
-
- -
- + +
+ + +
+
+
+ +
- -
-
-
- - -
+
-
-Back to movies +
+
+ Back to movie
{% endblock content %} {% block js %} - {% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap index 9a65856ff..ac848a6ef 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[edit]]@Htmx_scaffold.snap @@ -8,94 +8,32 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec Edit movie: {{ item.id }} {% endblock title %} +{% block page_title %} +Edit movie: {{ item.id }} +{% endblock page_title %} + {% block content %} -

Edit movie: {{ item.id }}

-
-
-
- -
- -
-
-
-
- - +
+ +
+ + +
+
+
+ + +
-
- -
-
-Back to movie + +
+
+ Back to movie
{% endblock content %} {% block js %} - {% endblock js %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[list]]@Html_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[list]]@Html_scaffold.snap index 844f23a28..8484a5717 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[list]]@Html_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[list]]@Html_scaffold.snap @@ -8,21 +8,69 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec List of movie {% endblock title %} +{% block page_title %} +movie +{% endblock page_title %} + {% block content %} -

movies

-{% for item in items %} + + {% if items %} +
-
- - +
+ + + + + + + + + {% for item in items %} + + + + + {% endfor %} + +
+ {{"title" | capitalize }} + + Actions +
+ {{item.title}} + + Edit +
+
+ +
-{% endfor %} -
-
-New movie + + {% else %} + +
+
+

Nothing Here Yet

+ There are no records to display. Add a new record to get started! + + Create + +
+
+ + {% endif %} + +
{% endblock content %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[list]]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[list]]@Htmx_scaffold.snap index 70c4c450c..8484a5717 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[list]]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[list]]@Htmx_scaffold.snap @@ -8,21 +8,69 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec List of movie {% endblock title %} +{% block page_title %} +movie +{% endblock page_title %} + {% block content %} -

movie

- {% for item in items %} + + {% if items %} +
-
- -
- Edit - View +
+ + + + + + + + + {% for item in items %} + + + + + {% endfor %} + +
+ {{"title" | capitalize }} + + Actions +
+ {{item.title}} + + Edit +
+
+ +
+ +
+
+ + {% else %} + +
+
+

Nothing Here Yet

+ There are no records to display. Add a new record to get started! + + Create +
- {% endfor %} +
+ + {% endif %} -
-
- New movie +
{% endblock content %} diff --git a/loco-gen/tests/templates/snapshots/generate[views_[show]]@Htmx_scaffold.snap b/loco-gen/tests/templates/snapshots/generate[views_[show]]@Htmx_scaffold.snap index 60b7d03f9..facc35f1a 100644 --- a/loco-gen/tests/templates/snapshots/generate[views_[show]]@Htmx_scaffold.snap +++ b/loco-gen/tests/templates/snapshots/generate[views_[show]]@Htmx_scaffold.snap @@ -8,8 +8,12 @@ expression: "fs::read_to_string(views_path.join(format!(\"{view}.html\"))).expec View movie: {{ item.id }} {% endblock title %} +{% block page_title %} +View movie: {{ item.id }} +{% endblock page_title %} + + {% block content %} -

View movie: {{ item.id }}

From 77118f7d0d5f3b9d1a7e8bf97cabb29c8d866a29 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Thu, 23 Jan 2025 15:40:40 +0200 Subject: [PATCH 15/26] more snap --- loco-gen/src/template_engine.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/loco-gen/src/template_engine.rs b/loco-gen/src/template_engine.rs index 113a212f3..f9c13b860 100644 --- a/loco-gen/src/template_engine.rs +++ b/loco-gen/src/template_engine.rs @@ -2,6 +2,7 @@ use std::collections::HashMap; use tera::{Tera, Value}; +#[must_use] pub fn new() -> Tera { let mut tera = Tera::default(); tera.register_function("render_form_field", FormField); From efe12b85ceca91eaa4a68d1ce53ef7f7966635ba Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Thu, 23 Jan 2025 15:50:16 +0200 Subject: [PATCH 16/26] more changes --- .github/workflows/loco-gen-e2e.yml | 4 ++-- docs-site/content/docs/the-app/models.md | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/loco-gen-e2e.yml b/.github/workflows/loco-gen-e2e.yml index 91eb1e4d4..24155bbc3 100644 --- a/.github/workflows/loco-gen-e2e.yml +++ b/.github/workflows/loco-gen-e2e.yml @@ -220,8 +220,8 @@ jobs: run: | cargo run -- generate scaffold --api room \ uuid_uniq:uuid \ - uuid_null:uuid_col \ - uuid:uuid_col! \ + uuid_null:uuid \ + uuid:uuid! \ string_null:string \ string:string! \ string_uniq:string^ \ diff --git a/docs-site/content/docs/the-app/models.md b/docs-site/content/docs/the-app/models.md index cd026a250..abcaa0253 100644 --- a/docs-site/content/docs/the-app/models.md +++ b/docs-site/content/docs/the-app/models.md @@ -129,9 +129,9 @@ These fields are ignored if you provide them in your migration command. For schema data types, you can use the following mapping to understand the schema: ```rust -("uuid", "uuid_uniq"), -("uuid_col", "uuid_null"), -("uuid_col!", "uuid"), +("uuid^", "uuid_uniq"), +("uuid", "uuid_null"), +("uuid!", "uuid"), ("string", "string_null"), ("string!", "string"), ("string^", "string_uniq"), From 15327060ad2e1f095d6bb464a0a0c17b16becfca Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 08:30:24 +0200 Subject: [PATCH 17/26] change file name --- loco-gen/src/lib.rs | 4 ++-- loco-gen/src/{template_engine.rs => tera_ext.rs} | 0 loco-gen/tests/templates/scaffold.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) rename loco-gen/src/{template_engine.rs => tera_ext.rs} (100%) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 0390143d6..61d43bbf9 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -24,7 +24,7 @@ mod model; #[cfg(feature = "with-db")] mod scaffold; pub mod template; -pub mod template_engine; +pub mod tera_ext; #[cfg(test)] mod testutil; @@ -273,7 +273,7 @@ pub struct AppInfo { #[must_use] pub fn new_generator() -> RRgen { - RRgen::default().add_template_engine(template_engine::new()) + RRgen::default().add_template_engine(tera_ext::new()) } /// Generate a component diff --git a/loco-gen/src/template_engine.rs b/loco-gen/src/tera_ext.rs similarity index 100% rename from loco-gen/src/template_engine.rs rename to loco-gen/src/tera_ext.rs diff --git a/loco-gen/tests/templates/scaffold.rs b/loco-gen/tests/templates/scaffold.rs index af9221fd3..8f2504d71 100644 --- a/loco-gen/tests/templates/scaffold.rs +++ b/loco-gen/tests/templates/scaffold.rs @@ -1,6 +1,6 @@ use super::utils::{guess_file_by_time, APP_ROUTS, MIGRATION_SRC_LIB}; use insta::{assert_snapshot, with_settings}; -use loco_gen::{collect_messages, generate, template_engine, AppInfo, Component, ScaffoldKind}; +use loco_gen::{collect_messages, generate, tera_ext, AppInfo, Component, ScaffoldKind}; use rrgen::RRgen; use rstest::rstest; use std::fs; @@ -37,7 +37,7 @@ fn can_generate(#[case] kind: ScaffoldKind) { .create() .unwrap(); - let rrgen = RRgen::with_working_dir(&tree_fs.root).add_template_engine(template_engine::new()); + let rrgen = RRgen::with_working_dir(&tree_fs.root).add_template_engine(tera_ext::new()); let gen_result = generate( &rrgen, From 29523db80e91dafcd139efefc4cb674ab32f5fa8 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 08:46:07 +0200 Subject: [PATCH 18/26] merge #1212 --- loco-gen/src/lib.rs | 66 +++++++++++++++---- loco-gen/src/mappings.json | 4 +- loco-gen/tests/db.rs | 31 +++++++-- .../tests/snapshots/db__migrations_flow.snap | 8 +-- .../snapshots/r#mod__db__migrations_flow.snap | 8 +-- 5 files changed, 92 insertions(+), 25 deletions(-) diff --git a/loco-gen/src/lib.rs b/loco-gen/src/lib.rs index 61d43bbf9..bb3ecef13 100644 --- a/loco-gen/src/lib.rs +++ b/loco-gen/src/lib.rs @@ -75,19 +75,20 @@ struct FieldType { #[derive(Debug, Deserialize, Serialize)] #[serde(untagged)] -enum RustType { +pub enum RustType { String(String), Map(HashMap), } #[derive(Serialize, Deserialize, Debug)] -struct Mappings { +pub struct Mappings { field_types: Vec, } impl Mappings { fn error_unrecognized_default_field(&self, field: &str) -> Error { - Self::error_unrecognized(field, &self.schema_fields()) + Self::error_unrecognized(field, &self.all_names()) } + fn error_unrecognized(field: &str, allow_fields: &[&String]) -> Error { Error::Message(format!( "type: `{}` not found. try any of: `{}`", @@ -99,6 +100,12 @@ impl Mappings { .join(",") )) } + + /// Resolves the Rust type for a given field with optional parameters. + /// + /// # Errors + /// + /// if rust field not exists or invalid parameters pub fn rust_field_with_params(&self, field: &str, params: &Vec) -> Result<&str> { match field { "array" | "array^" | "array!" => { @@ -112,7 +119,9 @@ impl Mappings { Err(self.error_unrecognized_default_field(field)) } } else { - panic!("array field should configured as array") + Err(Error::Message( + "array field should configured as array".to_owned(), + )) } } @@ -120,6 +129,11 @@ impl Mappings { } } + /// Resolves the Rust type for a given field. + /// + /// # Errors + /// + /// When the given field not recognized pub fn rust_field_kind(&self, field: &str) -> Result<&RustType> { self.field_types .iter() @@ -128,6 +142,11 @@ impl Mappings { .ok_or_else(|| self.error_unrecognized_default_field(field)) } + /// Resolves the Rust type for a given field. + /// + /// # Errors + /// + /// When the given field not recognized pub fn rust_field(&self, field: &str) -> Result<&str> { self.field_types .iter() @@ -143,6 +162,11 @@ impl Mappings { .map(std::string::String::as_str) } + /// Retrieves the schema field associated with the given field. + /// + /// # Errors + /// + /// When the given field not recognized pub fn schema_field(&self, field: &str) -> Result<&str> { self.field_types .iter() @@ -150,6 +174,12 @@ impl Mappings { .map(|f| f.schema.as_str()) .ok_or_else(|| self.error_unrecognized_default_field(field)) } + + /// Retrieves the column type field associated with the given field. + /// + /// # Errors + /// + /// When the given field not recognized pub fn col_type_field(&self, field: &str) -> Result<&str> { self.field_types .iter() @@ -157,6 +187,12 @@ impl Mappings { .map(|f| f.col_type.as_str()) .ok_or_else(|| self.error_unrecognized_default_field(field)) } + + /// Retrieves the column type arity associated with the given field. + /// + /// # Errors + /// + /// When the given field not recognized pub fn col_type_arity(&self, field: &str) -> Result { self.field_types .iter() @@ -164,14 +200,21 @@ impl Mappings { .map(|f| f.arity) .ok_or_else(|| self.error_unrecognized_default_field(field)) } - pub fn schema_fields(&self) -> Vec<&String> { + + #[must_use] + pub fn all_names(&self) -> Vec<&String> { self.field_types.iter().map(|f| &f.name).collect::>() } } static MAPPINGS: OnceLock = OnceLock::new(); -fn get_mappings() -> &'static Mappings { +/// Get type mapping for generation +/// +/// # Panics +/// +/// Panics if loading fails +pub fn get_mappings() -> &'static Mappings { MAPPINGS.get_or_init(|| { let json_data = include_str!("./mappings.json"); serde_json::from_str(json_data).expect("JSON was not well-formatted") @@ -419,9 +462,10 @@ pub fn collect_messages(results: &GenerateResults) -> String { /// Copies template files to a specified destination directory. /// -/// This function copies files from the specified template path to the destination directory. -/// If the specified path is `/` or `.`, it copies all files from the templates directory. -/// If the path does not exist in the templates, it returns an error. +/// This function copies files from the specified template path to the +/// destination directory. If the specified path is `/` or `.`, it copies all +/// files from the templates directory. If the path does not exist in the +/// templates, it returns an error. /// /// # Errors /// when could not copy the given template path @@ -567,10 +611,10 @@ mod tests { } #[test] - fn can_get_schema_fields_from_mapping() { + fn can_get_all_names_from_mapping() { let mapping = test_mapping(); assert_eq!( - mapping.schema_fields(), + mapping.all_names(), Vec::from([&"array".to_string(), &"string^".to_string()]) ); } diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index 2d438231f..17be89468 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -286,13 +286,13 @@ }, { "name": "ts", - "rust": "Option", + "rust": "Option>", "schema": "timestamp_null", "col_type": "TimestampNull" }, { "name": "ts!", - "rust": "DateTimeUtc", + "rust": "chrono::DateTime", "schema": "timestamp", "col_type": "Timestamp" }, diff --git a/loco-gen/tests/db.rs b/loco-gen/tests/db.rs index 797677f65..63cde5679 100644 --- a/loco-gen/tests/db.rs +++ b/loco-gen/tests/db.rs @@ -1,4 +1,5 @@ use std::{ + any::type_name, collections::HashMap, env::current_dir, fs::{self, read_to_string}, @@ -7,6 +8,7 @@ use std::{ use duct::cmd; use insta::assert_snapshot; +use loco_gen::get_mappings; use serial_test::serial; use uuid::Uuid; struct TestDir { @@ -36,7 +38,8 @@ fn test_migrations_flow() { let test_dir = TestDir::new(); let loco_dev_path = current_dir().unwrap(); let loco_dev_path = loco_dev_path.parent().unwrap(); - // when running locally set LOCO_DEV_MODE_PATH= + // 1. install most recent dev cli: cd loco-new; cargo install --path . --force + // 2. when running locally set LOCO_DEV_MODE_PATH= // LOCO_DEV_MODE_PATH=../../ cargo run -- new let mut env_map: HashMap<_, _> = std::env::vars().collect(); @@ -62,11 +65,31 @@ fn test_migrations_flow() { .run() .expect("new"); + // build a mega long all-types "title:string ..." pairs for all types from + // mappings.json name of column is name of type adjusted with unique, or + // nonnull, etc arity arguments get manual treatment + let mappings = get_mappings(); + let mut type_names = mappings + .all_names() + .iter() + // only take non-argument types because its easy + .filter(|n| mappings.col_type_arity(n).unwrap_or_default() == 0) + .map(|t| format!("{}:{t}", t.replace('!', "_nonull").replace('^', "_uniq"))) + .collect::>(); + + // push arity arguments manually + type_names.push("age:decimal_len:8:24".to_string()); + type_names.push("age_nonull:decimal_len!:8:24".to_string()); + + let types_line = type_names.join(" "); + let script = [ - "loco g scaffold playlists title:string --htmx", - "loco g model movies title:string playlist:references", + &format!("loco g scaffold playlists {types_line} --htmx"), + &format!("loco g model movies {types_line} playlist:references"), "loco g migration AddContentToMovies content:string", - "loco g migration CreateActors name:string experience:int age:decimal_len:8:24", + "loco g migration CreateActors foobar:string", + // TBD this errors under sqlite because they dont support alter and uniq + // &format!("loco g migration AddAllToActors {types_line}"), "loco g migration CreateJoinTableActorsAndMovies minutes:int", "loco g migration CreateAwards name:string actor:references", "loco g migration RemoveContentFromMovies content:string", diff --git a/loco-gen/tests/snapshots/db__migrations_flow.snap b/loco-gen/tests/snapshots/db__migrations_flow.snap index 8a7454e3b..4f1c4ca33 100644 --- a/loco-gen/tests/snapshots/db__migrations_flow.snap +++ b/loco-gen/tests/snapshots/db__migrations_flow.snap @@ -9,7 +9,7 @@ snapshot_kind: text "table": "actor_movies" }, { - "sql": "CREATE TABLE \"actors\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"name\" varchar NULL, \"experience\" integer NULL, \"age\" real(8, 24) NULL )", + "sql": "CREATE TABLE \"actors\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"foobar\" varchar NULL )", "table": "actors" }, { @@ -17,11 +17,11 @@ snapshot_kind: text "table": "awards" }, { - "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"title\" varchar NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", + "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", "table": "movies" }, { - "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"title\" varchar NULL )", + "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL )", "table": "playlists" }, { @@ -32,4 +32,4 @@ snapshot_kind: text "sql": "CREATE TABLE \"users\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"pid\" uuid_text NOT NULL, \"email\" varchar NOT NULL UNIQUE, \"password\" varchar NOT NULL, \"api_key\" varchar NOT NULL UNIQUE, \"name\" varchar NOT NULL, \"reset_token\" varchar NULL, \"reset_sent_at\" timestamp_with_timezone_text NULL, \"email_verification_token\" varchar NULL, \"email_verification_sent_at\" timestamp_with_timezone_text NULL, \"email_verified_at\" timestamp_with_timezone_text NULL, \"magic_link_token\" varchar NULL, \"magic_link_expiration\" timestamp_with_timezone_text NULL )", "table": "users" } -] +] \ No newline at end of file diff --git a/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap b/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap index 8a7454e3b..4f1c4ca33 100644 --- a/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap +++ b/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap @@ -9,7 +9,7 @@ snapshot_kind: text "table": "actor_movies" }, { - "sql": "CREATE TABLE \"actors\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"name\" varchar NULL, \"experience\" integer NULL, \"age\" real(8, 24) NULL )", + "sql": "CREATE TABLE \"actors\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"foobar\" varchar NULL )", "table": "actors" }, { @@ -17,11 +17,11 @@ snapshot_kind: text "table": "awards" }, { - "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"title\" varchar NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", + "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", "table": "movies" }, { - "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"title\" varchar NULL )", + "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL )", "table": "playlists" }, { @@ -32,4 +32,4 @@ snapshot_kind: text "sql": "CREATE TABLE \"users\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"pid\" uuid_text NOT NULL, \"email\" varchar NOT NULL UNIQUE, \"password\" varchar NOT NULL, \"api_key\" varchar NOT NULL UNIQUE, \"name\" varchar NOT NULL, \"reset_token\" varchar NULL, \"reset_sent_at\" timestamp_with_timezone_text NULL, \"email_verification_token\" varchar NULL, \"email_verification_sent_at\" timestamp_with_timezone_text NULL, \"email_verified_at\" timestamp_with_timezone_text NULL, \"magic_link_token\" varchar NULL, \"magic_link_expiration\" timestamp_with_timezone_text NULL )", "table": "users" } -] +] \ No newline at end of file From 80a468c8a5a203ee2a210846e24ed0922b00414b Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 09:20:27 +0200 Subject: [PATCH 19/26] mapping --- loco-gen/src/mappings.json | 49 ++++++++++++++++++++++++++++++++++++++ loco-gen/src/tera_ext.rs | 5 ++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index 17be89468..dbfb24215 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -48,6 +48,12 @@ "schema": "text", "col_type": "Text" }, + { + "name": "text^", + "rust": "String", + "schema": "text_uniq", + "col_type": "TextUniq" + }, { "name": "tiny_unsigned", "rust": "Option", @@ -186,6 +192,12 @@ "schema": "float", "col_type": "Float" }, + { + "name": "float^", + "rust": "f32", + "schema": "float_uniq", + "col_type": "FloatUniq" + }, { "name": "double", "rust": "Option", @@ -198,6 +210,12 @@ "schema": "double", "col_type": "Double" }, + { + "name": "double^", + "rust": "f64", + "schema": "double_uniq", + "col_type": "DoubleUniq" + }, { "name": "decimal", "rust": "Option", @@ -210,6 +228,12 @@ "schema": "decimal", "col_type": "Decimal" }, + { + "name": "decimal^", + "rust": "Decimal", + "schema": "decimal_uniq", + "col_type": "DecimalUniq" + }, { "name": "decimal_len", "rust": "Option", @@ -224,6 +248,13 @@ "col_type": "DecimalLen", "arity": 2 }, + { + "name": "decimal_len^", + "rust": "Decimal", + "schema": "decimal_len_uniq", + "col_type": "DecimalLenUniq", + "arity": 2 + }, { "name": "bool", "rust": "Option", @@ -308,6 +339,12 @@ "schema": "json", "col_type": "Json" }, + { + "name": "json^", + "rust": "serde_json::Value", + "schema": "json_uniq", + "col_type": "JsonUniq" + }, { "name": "jsonb", "rust": "Option", @@ -320,6 +357,12 @@ "schema": "json_binary", "col_type": "JsonBinary" }, + { + "name": "jsonb^", + "rust": "serde_json::Value", + "schema": "json_binary_uniq", + "col_type": "JsonBinaryUniq" + }, { "name": "blob", "rust": "Option>", @@ -332,6 +375,12 @@ "schema": "blob", "col_type": "Blob" }, + { + "name": "blob^", + "rust": "Vec", + "schema": "blob_uniq", + "col_type": "BlobUniq" + }, { "name": "money", "rust": "Option", diff --git a/loco-gen/src/tera_ext.rs b/loco-gen/src/tera_ext.rs index f9c13b860..553b1b22c 100644 --- a/loco-gen/src/tera_ext.rs +++ b/loco-gen/src/tera_ext.rs @@ -136,7 +136,9 @@ impl tera::Function for FormField { Some((f64::MIN, f64::MAX)), Some(r#"step="0.1""#), ), - "DateTimeWithTimeZone" + "chrono::DateTime" + | "Option>" + | "DateTimeWithTimeZone" | "Option" | "DateTime" | "Option" @@ -282,7 +284,6 @@ fn input_string( attr: Option<&str>, ) -> String { let attr = attr.unwrap_or_default(); - println!("is_required: {is_required}"); let required_value = if is_required { "required" } else { "" }; format!( r#""# From 9d7fc4ca1f9ea6fc7af3f8a74269c88816b9d0ec Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 10:14:47 +0200 Subject: [PATCH 20/26] docs --- docs-site/content/docs/the-app/models.md | 43 +++++++++++--- loco-gen/src/mappings.json | 75 ------------------------ loco-gen/src/tera_ext.rs | 4 +- src/schema.rs | 45 ++++++++------ 4 files changed, 63 insertions(+), 104 deletions(-) diff --git a/docs-site/content/docs/the-app/models.md b/docs-site/content/docs/the-app/models.md index abcaa0253..693c414b2 100644 --- a/docs-site/content/docs/the-app/models.md +++ b/docs-site/content/docs/the-app/models.md @@ -137,12 +137,16 @@ For schema data types, you can use the following mapping to understand the schem ("string^", "string_uniq"), ("text", "text_null"), ("text!", "text"), -("tiny_integer", "tiny_integer_null"), -("tiny_integer!", "tiny_integer"), -("tiny_integer^", "tiny_integer_uniq"), -("small_integer", "small_integer_null"), -("small_integer!", "small_integer"), -("small_integer^", "small_integer_uniq"), +("text^", "text_uniq"), +("small_unsigned^", "small_unsigned_uniq"), +("small_unsigned", "small_unsigned_null"), +("small_unsigned!", "small_unsigned"), +("big_unsigned^", "big_unsigned"), +("big_unsigned", "big_unsigned_null"), +("big_unsigned!", "big_unsigned_uniq"), +("small_int", "small_integer_null"), +("small_int!", "small_integer"), +("small_int^", "small_integer_uniq"), ("int", "integer_null"), ("int!", "integer"), ("int^", "integer_uniq"), @@ -151,24 +155,47 @@ For schema data types, you can use the following mapping to understand the schem ("big_int^", "big_integer_uniq"), ("float", "float_null"), ("float!", "float"), +("float^", "float_uniq"), ("double", "double_null"), ("double!", "double"), +("double^", "double_uniq"), ("decimal", "decimal_null"), ("decimal!", "decimal"), ("decimal_len", "decimal_len_null"), ("decimal_len!", "decimal_len"), +("decimal^", "decimal_uniq"), ("bool", "boolean_null"), ("bool!", "boolean"), ("tstz", "timestamp_with_time_zone_null"), ("tstz!", "timestamp_with_time_zone"), ("date", "date_null"), ("date!", "date"), -("ts", "timestamp_null"), -("ts!", "timestamp"), +("date^", "date_uniq"), +("date_time", "date_time_null"), +("date_time!", "date_time"), +("date_time^", "date_time_uniq"), +("blob", "blob_null"), +("blob!", "blob"), +("blob^", "blob_uniq"), ("json", "json_null"), ("json!", "json"), ("jsonb", "json_binary_null"), ("jsonb!", "json_binary"), +("jsonb^", "jsonb_uniq"), +("money", "money_null"), +("money!", "money"), +("money^", "money_uniq"), +("unsigned", "unsigned_null"), +("unsigned!", "unsigned"), +("unsigned^", "unsigned_uniq"), +("binary_len", "binary_len_null"), +("binary_len!", "binary_len"), +("binary_len^", "binary_len_uniq"), +("var_binary", "var_binary_null"), +("var_binary!", "var_binary"), +(" array", "array"), +(" array!", "array"), +(" array^", "array"), ``` Using `user:references` uses the special `references` type, which will create a relationship between a `post` and a `user`, adding a `user_id` reference field to the `posts` table. diff --git a/loco-gen/src/mappings.json b/loco-gen/src/mappings.json index dbfb24215..70f11ffc5 100644 --- a/loco-gen/src/mappings.json +++ b/loco-gen/src/mappings.json @@ -54,24 +54,6 @@ "schema": "text_uniq", "col_type": "TextUniq" }, - { - "name": "tiny_unsigned", - "rust": "Option", - "schema": "tiny_unsigned_null", - "col_type": "TinyUnsignedNull" - }, - { - "name": "tiny_unsigned!", - "rust": "i16", - "schema": "tiny_unsigned", - "col_type": "TinyUnsigned" - }, - { - "name": "tiny_unsigned^", - "rust": "i16", - "schema": "tiny_unsigned_uniq", - "col_type": "TinyUnsignedUniq" - }, { "name": "small_unsigned", "rust": "Option", @@ -108,24 +90,6 @@ "schema": "big_unsigned_uniq", "col_type": "BigUnsignedUniq" }, - { - "name": "tiny_int", - "rust": "Option", - "schema": "tiny_integer_null", - "col_type": "TinyIntegerNull" - }, - { - "name": "tiny_int!", - "rust": "i16", - "schema": "tiny_integer", - "col_type": "TinyInteger" - }, - { - "name": "tiny_int^", - "rust": "i16", - "schema": "tiny_integer_uniq", - "col_type": "TinyIntegerUniq" - }, { "name": "small_int", "rust": "Option", @@ -315,18 +279,6 @@ "schema": "date_time_uniq", "col_type": "DateTimeUniq" }, - { - "name": "ts", - "rust": "Option>", - "schema": "timestamp_null", - "col_type": "TimestampNull" - }, - { - "name": "ts!", - "rust": "chrono::DateTime", - "schema": "timestamp", - "col_type": "Timestamp" - }, { "name": "json", "rust": "Option", @@ -339,12 +291,6 @@ "schema": "json", "col_type": "Json" }, - { - "name": "json^", - "rust": "serde_json::Value", - "schema": "json_uniq", - "col_type": "JsonUniq" - }, { "name": "jsonb", "rust": "Option", @@ -459,27 +405,6 @@ "col_type": "VarBinaryUniq", "arity": 1 }, - { - "name": "varbit_len!", - "rust": "Vec", - "schema": "varbit", - "col_type": "VarBitLen", - "arity": 1 - }, - { - "name": "varbit_len", - "rust": "Option>", - "schema": "varbit_null", - "col_type": "VarBitLenNull", - "arity": 1 - }, - { - "name": "varbit_len^", - "rust": "Vec", - "schema": "varbit_uniq", - "col_type": "VarBitLenUniq", - "arity": 1 - }, { "name": "array!", "rust": { diff --git a/loco-gen/src/tera_ext.rs b/loco-gen/src/tera_ext.rs index 553b1b22c..9ee3478c5 100644 --- a/loco-gen/src/tera_ext.rs +++ b/loco-gen/src/tera_ext.rs @@ -136,9 +136,7 @@ impl tera::Function for FormField { Some((f64::MIN, f64::MAX)), Some(r#"step="0.1""#), ), - "chrono::DateTime" - | "Option>" - | "DateTimeWithTimeZone" + "DateTimeWithTimeZone" | "Option" | "DateTime" | "Option" diff --git a/src/schema.rs b/src/schema.rs index b5d4b4e0a..979120070 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -82,18 +82,24 @@ pub enum ColType { Unsigned, UnsignedNull, UnsignedUniq, - TinyUnsigned, - TinyUnsignedNull, - TinyUnsignedUniq, + // Tiny fields are not supported due to differences in data types between PostgreSQL and SQLite: + // * Postgres: i16 + // * Sqlite: i8 + // TinyUnsigned, + // TinyUnsignedNull, + // TinyUnsignedUniq, SmallUnsigned, SmallUnsignedNull, SmallUnsignedUniq, BigUnsigned, BigUnsignedNull, BigUnsignedUniq, - TinyInteger, - TinyIntegerNull, - TinyIntegerUniq, + // Tiny fields are not supported due to differences in data types between PostgreSQL and SQLite: + // * Postgres: i16 + // * Sqlite: i8 + // TinyInteger, + // TinyIntegerNull, + // TinyIntegerUniq, SmallInteger, SmallIntegerNull, SmallIntegerUniq, @@ -114,9 +120,12 @@ pub enum ColType { DoubleUniq, Boolean, BooleanNull, - Timestamp, - TimestampNull, - TimestampUniq, + // Timestamp fields are not supported due to differences in data types between PostgreSQL and SQLite: + // * Postgres: DateTime + // * Sqlite: DateTimeUtc + // Timestamp, + // TimestampNull, + // TimestampUniq, Date, DateNull, DateUniq, @@ -226,15 +235,15 @@ impl ColType { Self::Integer => integer(name), Self::IntegerNull => integer_null(name), Self::IntegerUniq => integer_uniq(name), - Self::TinyInteger => tiny_integer(name), - Self::TinyIntegerNull => tiny_integer_null(name), - Self::TinyIntegerUniq => tiny_integer_uniq(name), + // Self::TinyInteger => tiny_integer(name), + // Self::TinyIntegerNull => tiny_integer_null(name), + // Self::TinyIntegerUniq => tiny_integer_uniq(name), Self::Unsigned => unsigned(name), Self::UnsignedNull => unsigned_null(name), Self::UnsignedUniq => unsigned_uniq(name), - Self::TinyUnsigned => tiny_unsigned(name), - Self::TinyUnsignedNull => tiny_unsigned_null(name), - Self::TinyUnsignedUniq => tiny_unsigned_uniq(name), + // Self::TinyUnsigned => tiny_unsigned(name), + // Self::TinyUnsignedNull => tiny_unsigned_null(name), + // Self::TinyUnsignedUniq => tiny_unsigned_uniq(name), Self::SmallUnsigned => small_unsigned(name), Self::SmallUnsignedNull => small_unsigned_null(name), Self::SmallUnsignedUniq => small_unsigned_uniq(name), @@ -261,9 +270,9 @@ impl ColType { Self::DoubleUniq => double_uniq(name), Self::Boolean => boolean(name), Self::BooleanNull => boolean_null(name), - Self::Timestamp => timestamp(name), - Self::TimestampNull => timestamp_null(name), - Self::TimestampUniq => timestamp_uniq(name), + // Self::Timestamp => timestamp(name), + // Self::TimestampNull => timestamp_null(name), + // Self::TimestampUniq => timestamp_uniq(name), Self::Date => date(name), Self::DateNull => date_null(name), Self::DateUniq => date_uniq(name), From 269404f5cd672e974b3fbf1a5a3d0996cc05ef98 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 10:27:36 +0200 Subject: [PATCH 21/26] snap --- ...er_form_field_[form_tiny_int!_tiny_int!].snap | 14 -------------- ...er_form_field_[form_tiny_int^_tiny_int^].snap | 14 -------------- ...nder_form_field_[form_tiny_int_tiny_int].snap | 14 -------------- ...eld_[form_tiny_unsigned!_tiny_unsigned!].snap | 14 -------------- ...eld_[form_tiny_unsigned^_tiny_unsigned^].snap | 14 -------------- ...field_[form_tiny_unsigned_tiny_unsigned].snap | 14 -------------- ...ts__can_render_form_field_[form_ts!_ts!].snap | 14 -------------- ...ests__can_render_form_field_[form_ts_ts].snap | 14 -------------- ...orm_field_[form_varbit_len!_varbit_len!].snap | 16 ---------------- ...orm_field_[form_varbit_len^_varbit_len^].snap | 16 ---------------- ..._form_field_[form_varbit_len_varbit_len].snap | 16 ---------------- ...an_render_form_field_[form_array!_bool].snap} | 2 +- ..._render_form_field_[form_array!_double].snap} | 2 +- ...n_render_form_field_[form_array!_float].snap} | 2 +- ...can_render_form_field_[form_array!_int].snap} | 2 +- ..._render_form_field_[form_array!_string].snap} | 2 +- ...an_render_form_field_[form_array^_bool].snap} | 2 +- ..._render_form_field_[form_array^_double].snap} | 2 +- ...n_render_form_field_[form_array^_float].snap} | 2 +- ...can_render_form_field_[form_array^_int].snap} | 2 +- ..._render_form_field_[form_array^_string].snap} | 2 +- ...can_render_form_field_[form_array_bool].snap} | 2 +- ...n_render_form_field_[form_array_double].snap} | 2 +- ...an_render_form_field_[form_array_float].snap} | 2 +- ..._can_render_form_field_[form_array_int].snap} | 2 +- ...n_render_form_field_[form_array_string].snap} | 2 +- ...der_form_field_[form_big_int!_big_int!].snap} | 2 +- ...der_form_field_[form_big_int^_big_int^].snap} | 2 +- ...ender_form_field_[form_big_int_big_int].snap} | 2 +- ...ield_[form_big_unsigned!_big_unsigned!].snap} | 2 +- ...ield_[form_big_unsigned^_big_unsigned^].snap} | 2 +- ..._field_[form_big_unsigned_big_unsigned].snap} | 2 +- ...rm_field_[form_binary_len!_binary_len!].snap} | 2 +- ...rm_field_[form_binary_len^_binary_len^].snap} | 2 +- ...form_field_[form_binary_len_binary_len].snap} | 2 +- ...an_render_form_field_[form_blob!_blob!].snap} | 2 +- ...can_render_form_field_[form_blob^_blob^].snap | 16 ++++++++++++++++ ..._can_render_form_field_[form_blob_blob].snap} | 2 +- ...an_render_form_field_[form_bool!_bool!].snap} | 2 +- ..._can_render_form_field_[form_bool_bool].snap} | 2 +- ...an_render_form_field_[form_date!_date!].snap} | 2 +- ...an_render_form_field_[form_date^_date^].snap} | 2 +- ..._can_render_form_field_[form_date_date].snap} | 2 +- ...form_field_[form_date_time!_date_time!].snap} | 2 +- ...form_field_[form_date_time^_date_time^].snap} | 2 +- ...r_form_field_[form_date_time_date_time].snap} | 2 +- ...der_form_field_[form_decimal!_decimal!].snap} | 2 +- ...nder_form_field_[form_decimal^_decimal^].snap | 14 ++++++++++++++ ...ender_form_field_[form_decimal_decimal].snap} | 2 +- ..._field_[form_decimal_len!_decimal_len!].snap} | 2 +- ...m_field_[form_decimal_len^_decimal_len^].snap | 14 ++++++++++++++ ...rm_field_[form_decimal_len_decimal_len].snap} | 2 +- ...ender_form_field_[form_double!_double!].snap} | 2 +- ...render_form_field_[form_double^_double^].snap | 14 ++++++++++++++ ..._render_form_field_[form_double_double].snap} | 2 +- ..._render_form_field_[form_float!_float!].snap} | 2 +- ...n_render_form_field_[form_float^_float^].snap | 14 ++++++++++++++ ...an_render_form_field_[form_float_float].snap} | 2 +- ..._can_render_form_field_[form_int!_int!].snap} | 2 +- ..._can_render_form_field_[form_int^_int^].snap} | 2 +- ...s__can_render_form_field_[form_int_int].snap} | 2 +- ...an_render_form_field_[form_json!_json!].snap} | 2 +- ..._can_render_form_field_[form_json_json].snap} | 2 +- ..._render_form_field_[form_jsonb!_jsonb!].snap} | 2 +- ...n_render_form_field_[form_jsonb^_jsonb^].snap | 14 ++++++++++++++ ...an_render_form_field_[form_jsonb_jsonb].snap} | 2 +- ..._render_form_field_[form_money!_money!].snap} | 2 +- ..._render_form_field_[form_money^_money^].snap} | 2 +- ...an_render_form_field_[form_money_money].snap} | 2 +- ...form_field_[form_small_int!_small_int!].snap} | 2 +- ...form_field_[form_small_int^_small_int^].snap} | 2 +- ...r_form_field_[form_small_int_small_int].snap} | 2 +- ..._[form_small_unsigned!_small_unsigned!].snap} | 2 +- ..._[form_small_unsigned^_small_unsigned^].snap} | 2 +- ...ld_[form_small_unsigned_small_unsigned].snap} | 2 +- ...ender_form_field_[form_string!_string!].snap} | 2 +- ...ender_form_field_[form_string^_string^].snap} | 2 +- ..._render_form_field_[form_string_string].snap} | 2 +- ...an_render_form_field_[form_text!_text!].snap} | 2 +- ...can_render_form_field_[form_text^_text^].snap | 14 ++++++++++++++ ..._can_render_form_field_[form_text_text].snap} | 2 +- ...an_render_form_field_[form_tstz!_tstz!].snap} | 2 +- ..._can_render_form_field_[form_tstz_tstz].snap} | 2 +- ...r_form_field_[form_unsigned!_unsigned!].snap} | 2 +- ...r_form_field_[form_unsigned^_unsigned^].snap} | 2 +- ...der_form_field_[form_unsigned_unsigned].snap} | 2 +- ...an_render_form_field_[form_uuid!_uuid!].snap} | 2 +- ...an_render_form_field_[form_uuid^_uuid^].snap} | 2 +- ..._can_render_form_field_[form_uuid_uuid].snap} | 2 +- ...rm_field_[form_var_binary!_var_binary!].snap} | 2 +- ...rm_field_[form_var_binary^_var_binary^].snap} | 2 +- ...form_field_[form_var_binary_var_binary].snap} | 2 +- 92 files changed, 174 insertions(+), 234 deletions(-) delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap delete mode 100644 loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array!_bool].snap} (92%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array!_double].snap} (99%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array!_float].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array!_int].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array!_string].snap} (97%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array^_bool].snap} (92%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array^_double].snap} (99%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array^_float].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array^_int].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array^_string].snap} (97%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array_bool].snap} (92%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array_double].snap} (99%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array_float].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array_int].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_array_string].snap} (97%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_big_int!_big_int!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_big_int^_big_int^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_big_int_big_int].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len!_binary_len!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len^_binary_len^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len_binary_len].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_blob!_blob!].snap} (96%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob^_blob^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_blob_blob].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_bool!_bool!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_bool_bool].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_date!_date!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_date^_date^].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_date_date].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_date_time!_date_time!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_date_time^_date_time^].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_date_time_date_time].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_decimal!_decimal!].snap} (96%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal^_decimal^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_decimal].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap} (96%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len^_decimal_len^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len_decimal_len].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_double!_double!].snap} (98%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double^_double^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_double_double].snap} (98%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_float!_float!].snap} (96%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float^_float^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_float_float].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_int!_int!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_int^_int^].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_int_int].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_json!_json!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_json_json].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb!_jsonb!].snap} (95%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb^_jsonb^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb_jsonb].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_money!_money!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_money^_money^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_money_money].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_small_int!_small_int!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_small_int^_small_int^].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_small_int_small_int].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_string!_string!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_string^_string^].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_string_string].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_text!_text!].snap} (95%) create mode 100644 loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text^_text^].snap rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_text_text].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_tstz!_tstz!].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_tstz_tstz].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned!_unsigned!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned^_unsigned^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned_unsigned].snap} (95%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_uuid!_uuid!].snap} (97%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_uuid^_uuid^].snap} (97%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_uuid_uuid].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary!_var_binary!].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary^_var_binary^].snap} (96%) rename loco-gen/src/snapshots/{loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap => loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary_var_binary].snap} (96%) diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap deleted file mode 100644 index 903b3215e..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int!_tiny_int!].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap deleted file mode 100644 index f602ac229..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int^_tiny_int^].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap deleted file mode 100644 index d29f29ff5..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_int_tiny_int].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap deleted file mode 100644 index 75df99639..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned!_tiny_unsigned!].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap deleted file mode 100644 index 0670d9c05..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned^_tiny_unsigned^].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap deleted file mode 100644 index b9d86123f..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tiny_unsigned_tiny_unsigned].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap deleted file mode 100644 index 807aa2839..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts!_ts!].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap deleted file mode 100644 index 7d09d3f63..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_ts_ts].snap +++ /dev/null @@ -1,14 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -
- Edit Form -
- - -
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap deleted file mode 100644 index b6a429e8e..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len!_varbit_len!].snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -

e.g: 123,123,123 .

-
- Edit Form -
- - -

e.g: 123,123,123 .

-
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap deleted file mode 100644 index e14a1dae5..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len^_varbit_len^].snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -

e.g: 123,123,123 .

-
- Edit Form -
- - -

e.g: 123,123,123 .

-
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap b/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap deleted file mode 100644 index 3bc9ddb6a..000000000 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_varbit_len_varbit_len].snap +++ /dev/null @@ -1,16 +0,0 @@ ---- -source: loco-gen/src/template_engine.rs -expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" ---- -Crete form -
- - -

e.g: 123,123,123 .

-
- Edit Form -
- - -

e.g: 123,123,123 .

-
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_bool].snap similarity index 92% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_bool].snap index 601c2b010..029f435ea 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_bool].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_bool].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_double].snap similarity index 99% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_double].snap index f4a8e1f5a..b489a5a0f 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_double].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_double].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_float].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_float].snap index 3960f2a30..de8f17615 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_float].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_float].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_int].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_int].snap index a3ee01d67..1e3fb50f3 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_int].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_int].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_string].snap similarity index 97% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_string].snap index 45555fe85..be0911eae 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array!_string].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array!_string].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_bool].snap similarity index 92% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_bool].snap index bf862b16d..5624d819d 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_bool].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_bool].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_double].snap similarity index 99% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_double].snap index 0ebd54627..71da1b871 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_double].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_double].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_float].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_float].snap index 799d2d4b2..a56eb2fb6 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_float].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_float].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_int].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_int].snap index 035e81edf..0d3c5dbd6 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_int].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_int].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_string].snap similarity index 97% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_string].snap index 6fab61748..3f74e315b 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array^_string].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array^_string].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_bool].snap similarity index 92% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_bool].snap index 2dc195b1c..1cf6e392e 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_bool].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_bool].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_double].snap similarity index 99% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_double].snap index a1dc00ceb..532d8cbb2 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_double].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_double].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_float].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_float].snap index 843b98197..ecc1388c5 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_float].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_float].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_int].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_int].snap index db2cef54b..4708b00d5 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_int].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_int].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_string].snap similarity index 97% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_string].snap index 5b3f9338d..ff915e026 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_array_string].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_array_string].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int!_big_int!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int!_big_int!].snap index f465c46a8..62d69e7a5 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int!_big_int!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int!_big_int!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int^_big_int^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int^_big_int^].snap index d1772eaa4..71881c993 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int^_big_int^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int^_big_int^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int_big_int].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int_big_int].snap index 71f6e8c45..540bda187 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_int_big_int].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_int_big_int].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap index 6e7aac022..5729a5403 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned!_big_unsigned!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap index 54fb669f2..bd68c05ab 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned^_big_unsigned^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap index b0a256582..7294741de 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_big_unsigned_big_unsigned].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len!_binary_len!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len!_binary_len!].snap index a69f639b7..c79e10655 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len!_binary_len!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len!_binary_len!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len^_binary_len^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len^_binary_len^].snap index 0177b5ff4..689bec0c2 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len^_binary_len^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len^_binary_len^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len_binary_len].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len_binary_len].snap index fe6d30e9e..319e3c7f8 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_binary_len_binary_len].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_binary_len_binary_len].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob!_blob!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob!_blob!].snap index b084cfb50..3cc2eece0 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob!_blob!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob!_blob!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob^_blob^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob^_blob^].snap new file mode 100644 index 000000000..f63cc25b3 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob^_blob^].snap @@ -0,0 +1,16 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +

e.g: 123,123,123 .

+
+ Edit Form +
+ + +

e.g: 123,123,123 .

+
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob_blob].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob_blob].snap index 28f9ed7e1..92bd91223 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_blob_blob].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_blob_blob].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_bool!_bool!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_bool!_bool!].snap index 4db32abc9..308f512cc 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool!_bool!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_bool!_bool!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_bool_bool].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_bool_bool].snap index 14499808f..327dbf62f 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_bool_bool].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_bool_bool].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date!_date!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date!_date!].snap index b6bae2f94..6dc2f7ae5 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date!_date!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date!_date!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date^_date^].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date^_date^].snap index 85b3a3e58..14f7922c9 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date^_date^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date^_date^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_date].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_date].snap index b91684667..3b4ae98e7 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_date].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_date].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time!_date_time!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time!_date_time!].snap index 791ca0651..1a31db383 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time!_date_time!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time!_date_time!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time^_date_time^].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time^_date_time^].snap index b58f56e08..815ed392c 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time^_date_time^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time^_date_time^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time_date_time].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time_date_time].snap index 2c70b2c95..556c9e218 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_date_time_date_time].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_date_time_date_time].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal!_decimal!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal!_decimal!].snap index fbd9b3e91..1d160b618 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal!_decimal!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal!_decimal!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal^_decimal^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal^_decimal^].snap new file mode 100644 index 000000000..e18460768 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal^_decimal^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_decimal].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_decimal].snap index 211a4b92e..16208df22 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_decimal].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_decimal].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap index 9167657aa..64764dbb3 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len!_decimal_len!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len^_decimal_len^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len^_decimal_len^].snap new file mode 100644 index 000000000..cec362e3f --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len^_decimal_len^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len_decimal_len].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len_decimal_len].snap index 9a6780be0..90027aaa3 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_decimal_len_decimal_len].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_decimal_len_decimal_len].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double!_double!].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double!_double!].snap index e06285a83..a23b3134d 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double!_double!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double!_double!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double^_double^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double^_double^].snap new file mode 100644 index 000000000..284780197 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double^_double^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double_double].snap similarity index 98% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double_double].snap index a119a204c..c4611e673 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_double_double].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_double_double].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float!_float!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float!_float!].snap index 6a54380c5..a9b10fe87 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float!_float!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float!_float!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float^_float^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float^_float^].snap new file mode 100644 index 000000000..5b0d5604e --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float^_float^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float_float].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float_float].snap index bb89b40f7..b8ab4fa96 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_float_float].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_float_float].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int!_int!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int!_int!].snap index 0355efab2..8b909e645 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int!_int!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int!_int!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int^_int^].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int^_int^].snap index dfa074752..2983fbe4a 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int^_int^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int^_int^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int_int].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int_int].snap index 156f92617..b36589548 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_int_int].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_int_int].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_json!_json!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_json!_json!].snap index a2f10db85..6bef54f0e 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json!_json!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_json!_json!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_json_json].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_json_json].snap index 8cc60ccfd..a06a82911 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_json_json].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_json_json].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb!_jsonb!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb!_jsonb!].snap index 48d7286da..d98509dc5 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb!_jsonb!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb!_jsonb!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb^_jsonb^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb^_jsonb^].snap new file mode 100644 index 000000000..7a83ddd10 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb^_jsonb^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb_jsonb].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb_jsonb].snap index bb3fbcbbb..b35f5717e 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_jsonb_jsonb].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_jsonb_jsonb].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money!_money!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money!_money!].snap index 2e66e3209..237accc96 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money!_money!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money!_money!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money^_money^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money^_money^].snap index 382d495df..120f647ba 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money^_money^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money^_money^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money_money].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money_money].snap index 5c0c430d8..6f3c77a17 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_money_money].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_money_money].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int!_small_int!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int!_small_int!].snap index 7f7ca2984..e46da51da 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int!_small_int!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int!_small_int!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int^_small_int^].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int^_small_int^].snap index e9157d5b9..522de4ad4 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int^_small_int^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int^_small_int^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int_small_int].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int_small_int].snap index a7bc47687..b03774090 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_int_small_int].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_int_small_int].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap index 93b633178..4a8b76603 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned!_small_unsigned!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap index 9ee0f80e3..f30d3bca4 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned^_small_unsigned^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap index ff730e156..22e78bc10 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_small_unsigned_small_unsigned].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string!_string!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string!_string!].snap index 4e20b9d85..1e104a04e 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string!_string!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string!_string!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string^_string^].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string^_string^].snap index 538a3c4c5..3df7eb357 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string^_string^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string^_string^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string_string].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string_string].snap index 8c7d67b4b..4de146df4 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_string_string].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_string_string].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text!_text!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text!_text!].snap index 5b350073c..0a98ce532 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text!_text!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text!_text!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text^_text^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text^_text^].snap new file mode 100644 index 000000000..22045d6f5 --- /dev/null +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text^_text^].snap @@ -0,0 +1,14 @@ +--- +source: loco-gen/src/tera_ext.rs +expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" +--- +Crete form +
+ + +
+ Edit Form +
+ + +
diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text_text].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text_text].snap index bd99b20a0..388c6db75 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_text_text].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_text_text].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_tstz!_tstz!].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_tstz!_tstz!].snap index 56a977523..e61b0d7ce 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz!_tstz!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_tstz!_tstz!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_tstz_tstz].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_tstz_tstz].snap index 6c0b67024..d07735c16 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_tstz_tstz].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_tstz_tstz].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned!_unsigned!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned!_unsigned!].snap index ae206e234..de69df079 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned!_unsigned!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned!_unsigned!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned^_unsigned^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned^_unsigned^].snap index 7a5022a3e..ec99dc830 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned^_unsigned^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned^_unsigned^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned_unsigned].snap similarity index 95% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned_unsigned].snap index 43add08df..2fa20c2f6 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_unsigned_unsigned].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_unsigned_unsigned].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid!_uuid!].snap similarity index 97% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid!_uuid!].snap index 7231cd3e5..58aa686fd 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid!_uuid!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid!_uuid!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid^_uuid^].snap similarity index 97% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid^_uuid^].snap index 95fc4cb0a..a18772413 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid^_uuid^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid^_uuid^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid_uuid].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid_uuid].snap index 8eefd95b8..e04c55893 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_uuid_uuid].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_uuid_uuid].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary!_var_binary!].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary!_var_binary!].snap index 6a819f464..bcca5ca8e 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary!_var_binary!].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary!_var_binary!].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary^_var_binary^].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary^_var_binary^].snap index 6dad69da3..a78b72acb 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary^_var_binary^].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary^_var_binary^].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form diff --git a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary_var_binary].snap similarity index 96% rename from loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap rename to loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary_var_binary].snap index 727659562..86cdb7dfc 100644 --- a/loco-gen/src/snapshots/loco_gen__template_engine__tests__can_render_form_field_[form_var_binary_var_binary].snap +++ b/loco-gen/src/snapshots/loco_gen__tera_ext__tests__can_render_form_field_[form_var_binary_var_binary].snap @@ -1,5 +1,5 @@ --- -source: loco-gen/src/template_engine.rs +source: loco-gen/src/tera_ext.rs expression: "format!(\"Crete form\\n\\r{create_form}\\n\\rEdit Form\\n\\r{edit_form}\")" --- Crete form From e87cc1d18d9afbecc08e6743ec7005643a33ace6 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 11:05:26 +0200 Subject: [PATCH 22/26] test html and htmx only when asset is provided --- loco-new/tests/wizard/new.rs | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/loco-new/tests/wizard/new.rs b/loco-new/tests/wizard/new.rs index b6f1f5183..32b9c4cbd 100644 --- a/loco-new/tests/wizard/new.rs +++ b/loco-new/tests/wizard/new.rs @@ -77,7 +77,7 @@ fn test_combination( let wizard_selection = wizard::Selections { db: db.clone(), background: background.clone(), - asset, + asset: asset.clone(), }; let settings = settings::Settings::from_wizard("test-loco-template", &wizard_selection, OS::default()); @@ -111,23 +111,25 @@ fn test_combination( "get_note", ]); - // Generate HTMX controller - tester.run_generate(&vec![ - "controller", - "notes_htmx", - "--htmx", - "create_note", - "get_note", - ]); + if asset.enable() { + // Generate HTMX controller + tester.run_generate(&vec![ + "controller", + "notes_htmx", + "--htmx", + "create_note", + "get_note", + ]); - // Generate HTML controller - tester.run_generate(&vec![ - "controller", - "notes_html", - "--html", - "create_note", - "get_note", - ]); + // Generate HTML controller + tester.run_generate(&vec![ + "controller", + "notes_html", + "--html", + "create_note", + "get_note", + ]); + } // Generate Task tester.run_generate(&vec!["task", "list_users"]); From a074ed1cffda9fab2aeba7bd3856d283a3860beb Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 11:12:23 +0200 Subject: [PATCH 23/26] snap --- loco-gen/tests/db.rs | 1 - loco-gen/tests/snapshots/db__migrations_flow.snap | 7 +++---- loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap | 7 +++---- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/loco-gen/tests/db.rs b/loco-gen/tests/db.rs index 63cde5679..c8032b515 100644 --- a/loco-gen/tests/db.rs +++ b/loco-gen/tests/db.rs @@ -1,5 +1,4 @@ use std::{ - any::type_name, collections::HashMap, env::current_dir, fs::{self, read_to_string}, diff --git a/loco-gen/tests/snapshots/db__migrations_flow.snap b/loco-gen/tests/snapshots/db__migrations_flow.snap index 4f1c4ca33..b980bd13d 100644 --- a/loco-gen/tests/snapshots/db__migrations_flow.snap +++ b/loco-gen/tests/snapshots/db__migrations_flow.snap @@ -1,7 +1,6 @@ --- source: loco-gen/tests/db.rs expression: "read_to_string(test_dir.path.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" -snapshot_kind: text --- [ { @@ -17,11 +16,11 @@ snapshot_kind: text "table": "awards" }, { - "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", + "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid_uniq\" uuid_text NOT NULL UNIQUE, \"uuid\" uuid_text NULL, \"uuid_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"text_uniq\" text NOT NULL UNIQUE, \"small_unsigned\" smallint NULL, \"small_unsigned_nonull\" smallint NOT NULL, \"small_unsigned_uniq\" smallint NOT NULL UNIQUE, \"big_unsigned\" bigint NULL, \"big_unsigned_nonull\" bigint NOT NULL, \"big_unsigned_uniq\" bigint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"float_uniq\" float NOT NULL UNIQUE, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"double_uniq\" double NOT NULL UNIQUE, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"decimal_uniq\" real NOT NULL UNIQUE, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"date_uniq\" date_text NOT NULL UNIQUE, \"date_time\" datetime_text NULL, \"date_time_nonull\" datetime_text NOT NULL, \"date_time_uniq\" datetime_text NOT NULL UNIQUE, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"jsonb_uniq\" jsonb_text NOT NULL UNIQUE, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"blob_uniq\" blob NOT NULL UNIQUE, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"money_uniq\" real_money NOT NULL UNIQUE, \"unsigned_nonull\" integer NOT NULL, \"unsigned\" integer NULL, \"unsigned_uniq\" integer NOT NULL UNIQUE, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", "table": "movies" }, { - "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL )", + "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid_uniq\" uuid_text NOT NULL UNIQUE, \"uuid\" uuid_text NULL, \"uuid_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"text_uniq\" text NOT NULL UNIQUE, \"small_unsigned\" smallint NULL, \"small_unsigned_nonull\" smallint NOT NULL, \"small_unsigned_uniq\" smallint NOT NULL UNIQUE, \"big_unsigned\" bigint NULL, \"big_unsigned_nonull\" bigint NOT NULL, \"big_unsigned_uniq\" bigint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"float_uniq\" float NOT NULL UNIQUE, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"double_uniq\" double NOT NULL UNIQUE, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"decimal_uniq\" real NOT NULL UNIQUE, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"date_uniq\" date_text NOT NULL UNIQUE, \"date_time\" datetime_text NULL, \"date_time_nonull\" datetime_text NOT NULL, \"date_time_uniq\" datetime_text NOT NULL UNIQUE, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"jsonb_uniq\" jsonb_text NOT NULL UNIQUE, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"blob_uniq\" blob NOT NULL UNIQUE, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"money_uniq\" real_money NOT NULL UNIQUE, \"unsigned_nonull\" integer NOT NULL, \"unsigned\" integer NULL, \"unsigned_uniq\" integer NOT NULL UNIQUE, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL )", "table": "playlists" }, { @@ -32,4 +31,4 @@ snapshot_kind: text "sql": "CREATE TABLE \"users\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"pid\" uuid_text NOT NULL, \"email\" varchar NOT NULL UNIQUE, \"password\" varchar NOT NULL, \"api_key\" varchar NOT NULL UNIQUE, \"name\" varchar NOT NULL, \"reset_token\" varchar NULL, \"reset_sent_at\" timestamp_with_timezone_text NULL, \"email_verification_token\" varchar NULL, \"email_verification_sent_at\" timestamp_with_timezone_text NULL, \"email_verified_at\" timestamp_with_timezone_text NULL, \"magic_link_token\" varchar NULL, \"magic_link_expiration\" timestamp_with_timezone_text NULL )", "table": "users" } -] \ No newline at end of file +] diff --git a/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap b/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap index 4f1c4ca33..b980bd13d 100644 --- a/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap +++ b/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap @@ -1,7 +1,6 @@ --- source: loco-gen/tests/db.rs expression: "read_to_string(test_dir.path.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" -snapshot_kind: text --- [ { @@ -17,11 +16,11 @@ snapshot_kind: text "table": "awards" }, { - "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", + "sql": "CREATE TABLE \"movies\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid_uniq\" uuid_text NOT NULL UNIQUE, \"uuid\" uuid_text NULL, \"uuid_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"text_uniq\" text NOT NULL UNIQUE, \"small_unsigned\" smallint NULL, \"small_unsigned_nonull\" smallint NOT NULL, \"small_unsigned_uniq\" smallint NOT NULL UNIQUE, \"big_unsigned\" bigint NULL, \"big_unsigned_nonull\" bigint NOT NULL, \"big_unsigned_uniq\" bigint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"float_uniq\" float NOT NULL UNIQUE, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"double_uniq\" double NOT NULL UNIQUE, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"decimal_uniq\" real NOT NULL UNIQUE, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"date_uniq\" date_text NOT NULL UNIQUE, \"date_time\" datetime_text NULL, \"date_time_nonull\" datetime_text NOT NULL, \"date_time_uniq\" datetime_text NOT NULL UNIQUE, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"jsonb_uniq\" jsonb_text NOT NULL UNIQUE, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"blob_uniq\" blob NOT NULL UNIQUE, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"money_uniq\" real_money NOT NULL UNIQUE, \"unsigned_nonull\" integer NOT NULL, \"unsigned\" integer NULL, \"unsigned_uniq\" integer NOT NULL UNIQUE, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL, \"playlist_id\" integer NOT NULL, \"rating\" integer NULL, FOREIGN KEY (\"playlist_id\") REFERENCES \"playlists\" (\"id\") ON DELETE CASCADE ON UPDATE CASCADE )", "table": "movies" }, { - "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid\" uuid_text NOT NULL UNIQUE, \"uuid_col\" uuid_text NULL, \"uuid_col_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"tiny_int\" tinyint NULL, \"tiny_int_nonull\" tinyint NOT NULL, \"tiny_int_uniq\" tinyint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"ts\" timestamp_text NULL, \"ts_nonull\" timestamp_text NOT NULL, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL )", + "sql": "CREATE TABLE \"playlists\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"uuid_uniq\" uuid_text NOT NULL UNIQUE, \"uuid\" uuid_text NULL, \"uuid_nonull\" uuid_text NOT NULL, \"string\" varchar NULL, \"string_nonull\" varchar NOT NULL, \"string_uniq\" varchar NOT NULL UNIQUE, \"text\" text NULL, \"text_nonull\" text NOT NULL, \"text_uniq\" text NOT NULL UNIQUE, \"small_unsigned\" smallint NULL, \"small_unsigned_nonull\" smallint NOT NULL, \"small_unsigned_uniq\" smallint NOT NULL UNIQUE, \"big_unsigned\" bigint NULL, \"big_unsigned_nonull\" bigint NOT NULL, \"big_unsigned_uniq\" bigint NOT NULL UNIQUE, \"small_int\" smallint NULL, \"small_int_nonull\" smallint NOT NULL, \"small_int_uniq\" smallint NOT NULL UNIQUE, \"int\" integer NULL, \"int_nonull\" integer NOT NULL, \"int_uniq\" integer NOT NULL UNIQUE, \"big_int\" bigint NULL, \"big_int_nonull\" bigint NOT NULL, \"big_int_uniq\" bigint NOT NULL UNIQUE, \"float\" float NULL, \"float_nonull\" float NOT NULL, \"float_uniq\" float NOT NULL UNIQUE, \"double\" double NULL, \"double_nonull\" double NOT NULL, \"double_uniq\" double NOT NULL UNIQUE, \"decimal\" real NULL, \"decimal_nonull\" real NOT NULL, \"decimal_uniq\" real NOT NULL UNIQUE, \"bool\" boolean NULL, \"bool_nonull\" boolean NOT NULL, \"tstz\" timestamp_with_timezone_text, \"tstz_nonull\" timestamp_with_timezone_text NOT NULL, \"date\" date_text NULL, \"date_nonull\" date_text NOT NULL, \"date_uniq\" date_text NOT NULL UNIQUE, \"date_time\" datetime_text NULL, \"date_time_nonull\" datetime_text NOT NULL, \"date_time_uniq\" datetime_text NOT NULL UNIQUE, \"json\" json_text NULL, \"json_nonull\" json_text NOT NULL, \"jsonb\" jsonb_text NULL, \"jsonb_nonull\" jsonb_text NOT NULL, \"jsonb_uniq\" jsonb_text NOT NULL UNIQUE, \"blob\" blob NULL, \"blob_nonull\" blob NOT NULL, \"blob_uniq\" blob NOT NULL UNIQUE, \"money\" real_money NULL, \"money_nonull\" real_money NOT NULL, \"money_uniq\" real_money NOT NULL UNIQUE, \"unsigned_nonull\" integer NOT NULL, \"unsigned\" integer NULL, \"unsigned_uniq\" integer NOT NULL UNIQUE, \"age\" real(8, 24) NULL, \"age_nonull\" real(8, 24) NOT NULL )", "table": "playlists" }, { @@ -32,4 +31,4 @@ snapshot_kind: text "sql": "CREATE TABLE \"users\" ( \"created_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"updated_at\" timestamp_with_timezone_text NOT NULL DEFAULT CURRENT_TIMESTAMP, \"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"pid\" uuid_text NOT NULL, \"email\" varchar NOT NULL UNIQUE, \"password\" varchar NOT NULL, \"api_key\" varchar NOT NULL UNIQUE, \"name\" varchar NOT NULL, \"reset_token\" varchar NULL, \"reset_sent_at\" timestamp_with_timezone_text NULL, \"email_verification_token\" varchar NULL, \"email_verification_sent_at\" timestamp_with_timezone_text NULL, \"email_verified_at\" timestamp_with_timezone_text NULL, \"magic_link_token\" varchar NULL, \"magic_link_expiration\" timestamp_with_timezone_text NULL )", "table": "users" } -] \ No newline at end of file +] From 25baedf3158d2b67f419d1540ea440cc1e3babf4 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 15:32:42 +0200 Subject: [PATCH 24/26] pg tests --- .github/workflows/loco-gen-e2e.yml | 266 ------ loco-gen/tests/db.rs | 74 +- .../db__migrations_flow_postgres.snap | 836 ++++++++++++++++++ ...w.snap => db__migrations_flow_sqlite.snap} | 2 +- .../r#mod__db__migrations_flow_postgres.snap | 836 ++++++++++++++++++ ...=> r#mod__db__migrations_flow_sqlite.snap} | 2 +- loco-new/tests/wizard/new.rs | 36 +- 7 files changed, 1729 insertions(+), 323 deletions(-) delete mode 100644 .github/workflows/loco-gen-e2e.yml create mode 100644 loco-gen/tests/snapshots/db__migrations_flow_postgres.snap rename loco-gen/tests/snapshots/{db__migrations_flow.snap => db__migrations_flow_sqlite.snap} (98%) create mode 100644 loco-gen/tests/snapshots/r#mod__db__migrations_flow_postgres.snap rename loco-gen/tests/snapshots/{r#mod__db__migrations_flow.snap => r#mod__db__migrations_flow_sqlite.snap} (98%) diff --git a/.github/workflows/loco-gen-e2e.yml b/.github/workflows/loco-gen-e2e.yml deleted file mode 100644 index 24155bbc3..000000000 --- a/.github/workflows/loco-gen-e2e.yml +++ /dev/null @@ -1,266 +0,0 @@ -name: "[loco-gen:e2e]" - -on: - push: - branches: - - master - paths: - - "loco-gen/**" - pull_request: - paths: - - "loco-gen/**" - -env: - RUST_TOOLCHAIN: stable - TOOLCHAIN_PROFILE: minimal - -jobs: - test: - name: test-generate - runs-on: ubuntu-latest - - permissions: - contents: read - - services: - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - "6379:6379" - postgres: - image: postgres - env: - POSTGRES_DB: postgres_test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - # Set health checks to wait until postgres has started - options: --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - - name: Install seaorm cli - run: cargo install sea-orm-cli - - - name: scaffold - run: cargo run -- generate scaffold --htmx car name:string year:int && cargo build - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: model - run: cargo run -- generate model post title:string content:text && cargo build - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: controller - run: cargo run -- generate controller pages about --htmx && cargo build && cargo test pages - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: worker - run: cargo run -- generate worker report_worker && cargo build && cargo test workers::report_worker::test_run_report_worker_worker - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: mailer - run: cargo run -- generate mailer birthday_mailer && cargo build - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: task - run: cargo run -- generate task mytask && cargo build && cargo test tasks::mytask::test_can_run_mytask - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: scheduler - run: cargo run -- generate scheduler - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - - name: docker deployment - run: cargo run -- generate deployment --kind docker - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test - - model_fields_generator: - name: test-fields - runs-on: ubuntu-latest - strategy: - matrix: - db: - - "postgres://postgres:postgres@localhost:5432/postgres_test" - # XXX: need to clean up demo first - # - "sqlite://loco_app.sqlite?mode=rwc" - - permissions: - contents: read - - services: - redis: - image: redis - options: >- - --health-cmd "redis-cli ping" - --health-interval 10s - --health-timeout 5s - --health-retries 5 - ports: - - "6379:6379" - postgres: - image: postgres - env: - POSTGRES_DB: postgres_test - POSTGRES_USER: postgres - POSTGRES_PASSWORD: postgres - ports: - - "5432:5432" - # Set health checks to wait until postgres has started - options: --health-cmd pg_isready - --health-interval 10s - --health-timeout 5s - --health-retries 5 - - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - toolchain: ${{ env.RUST_TOOLCHAIN }} - - name: Setup Rust cache - uses: Swatinem/rust-cache@v2 - - - name: Install seaorm cli - run: cargo install sea-orm-cli - - - name: test ${{ matrix.field_type }} model field type - run: | - cargo run -- generate model post \ - uuid_uniq:uuid \ - uuid_null:uuid \ - uuid:uuid! \ - string_null:string \ - string:string! \ - string_uniq:string^ \ - text_null:text \ - text:text! \ - tiny_integer_null:tiny_int \ - tiny_integer:tiny_int! \ - tiny_integer_uniq:tiny_int^ \ - small_integer_null:small_int \ - small_integer:small_int! \ - small_integer_uniq:small_int^ \ - integer_null:int \ - integer:int! \ - integer_uniq:int^ \ - big_integer_null:big_int \ - big_integer:big_int! \ - big_integer_uniq:big_int^ \ - float_null:float \ - float:float! \ - double_null:double \ - double:double! \ - decimal_null:decimal \ - decimal:decimal! \ - decimal_len_null:decimal_len:8:24 \ - decimal_len:decimal_len!:8:24 \ - boolean_null:bool \ - boolean:bool! \ - timestamp_with_time_zone_null:tstz \ - timestamp_with_time_zone:tstz! \ - date_null:date \ - date:date! \ - timestamp_null:ts \ - timestamp:ts! \ - json_null:json \ - json:json! \ - json_binary_null:jsonb \ - json_binary:jsonb! \ - blob_null:blob \ - blob:blob! \ - money_null:money \ - money:money! \ - && cargo build - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: ${{matrix.db}} - - - name: test ${{ matrix.field_type }} scaffold field type - run: | - cargo run -- generate scaffold --api room \ - uuid_uniq:uuid \ - uuid_null:uuid \ - uuid:uuid! \ - string_null:string \ - string:string! \ - string_uniq:string^ \ - text_null:text \ - text:text! \ - tiny_integer_null:tiny_int \ - tiny_integer:tiny_int! \ - tiny_integer_uniq:tiny_int^ \ - small_integer_null:small_int \ - small_integer:small_int! \ - small_integer_uniq:small_int^ \ - integer_null:int \ - integer:int! \ - integer_uniq:int^ \ - big_integer_null:big_int \ - big_integer:big_int! \ - big_integer_uniq:big_int^ \ - float_null:float \ - float:float! \ - double_null:double \ - double:double! \ - decimal_null:decimal \ - decimal:decimal! \ - decimal_len_null:decimal_len:8:24 \ - decimal_len:decimal_len!:8:24 \ - boolean_null:bool \ - boolean:bool! \ - timestamp_with_time_zone_null:tstz \ - timestamp_with_time_zone:tstz! \ - date_null:date \ - date:date! \ - timestamp_null:ts \ - timestamp:ts! \ - json_null:json \ - json:json! \ - json_binary_null:jsonb \ - json_binary:jsonb! \ - && cargo build - working-directory: ./examples/demo - env: - REDIS_URL: redis://localhost:${{job.services.redis.ports[6379]}} - DATABASE_URL: ${{matrix.db}} diff --git a/loco-gen/tests/db.rs b/loco-gen/tests/db.rs index c8032b515..47ff4c6a1 100644 --- a/loco-gen/tests/db.rs +++ b/loco-gen/tests/db.rs @@ -1,58 +1,43 @@ -use std::{ - collections::HashMap, - env::current_dir, - fs::{self, read_to_string}, - path::PathBuf, -}; - use duct::cmd; use insta::assert_snapshot; use loco_gen::get_mappings; +use rstest::rstest; use serial_test::serial; -use uuid::Uuid; -struct TestDir { - pub path: PathBuf, -} - -impl TestDir { - fn new() -> Self { - let path = std::env::temp_dir() - .join("loco-test-generator") - .join(Uuid::new_v4().to_string()); - - fs::create_dir_all(&path).unwrap(); - Self { path } - } -} - -impl Drop for TestDir { - fn drop(&mut self) { - let _ = fs::remove_dir_all(&self.path); - } -} +use std::{collections::HashMap, env::current_dir, fs::read_to_string}; -#[test] +#[rstest] #[serial] -fn test_migrations_flow() { - let test_dir = TestDir::new(); +fn test_migrations_flow(#[values("postgres", "sqlite")] db_kind: &str) { + if db_kind == "postgres" && std::env::var("DATABASE_URL").is_err() { + return; + } + let tree_fs = tree_fs::TreeBuilder::default() + .drop(true) + .create() + .expect("Should create temp folder"); let loco_dev_path = current_dir().unwrap(); let loco_dev_path = loco_dev_path.parent().unwrap(); // 1. install most recent dev cli: cd loco-new; cargo install --path . --force // 2. when running locally set LOCO_DEV_MODE_PATH= // LOCO_DEV_MODE_PATH=../../ cargo run -- new - let mut env_map: HashMap<_, _> = std::env::vars().collect(); + let mut env_map: HashMap = std::env::vars().collect(); env_map.insert( "LOCO_DEV_MODE_PATH".into(), loco_dev_path.to_str().unwrap().to_string(), ); + + if db_kind == "sqlite" { + env_map.remove("DATABASE_URL"); + } + cmd!( "loco", "new", "-n", "myapp", "--db", - "sqlite", + db_kind, "--bg", "async", "--assets", @@ -60,7 +45,7 @@ fn test_migrations_flow() { "-a" ) .full_env(&env_map) - .dir(test_dir.path.as_path()) + .dir(&tree_fs.root) .run() .expect("new"); @@ -80,14 +65,23 @@ fn test_migrations_flow() { type_names.push("age:decimal_len:8:24".to_string()); type_names.push("age_nonull:decimal_len!:8:24".to_string()); + if db_kind == "postgres" { + type_names.push("array_string:array:string".to_string()); + type_names.push("array_float:array:float".to_string()); + type_names.push("array_int:array:int".to_string()); + type_names.push("array_double:array:double".to_string()); + type_names.push("array_bool:array:bool".to_string()); + } + let types_line = type_names.join(" "); let script = [ + "loco db reset", &format!("loco g scaffold playlists {types_line} --htmx"), &format!("loco g model movies {types_line} playlist:references"), "loco g migration AddContentToMovies content:string", "loco g migration CreateActors foobar:string", - // TBD this errors under sqlite because they dont support alter and uniq + // TBD this errors under sqlite because they don`t support alter and uniq // &format!("loco g migration AddAllToActors {types_line}"), "loco g migration CreateJoinTableActorsAndMovies minutes:int", "loco g migration CreateAwards name:string actor:references", @@ -101,9 +95,13 @@ fn test_migrations_flow() { for line in script { cmd("cargo", line.split(' ')) .full_env(&env_map) - .dir(test_dir.path.join("myapp")) + .dir(tree_fs.root.join("myapp")) .run() - .expect("scaffold"); + .unwrap_or_else(|_| panic!("command {line} should run successfully")); } - assert_snapshot!(read_to_string(test_dir.path.join("myapp").join("schema_dump.json")).unwrap()); + // cargo loco build + assert_snapshot!( + format!("migrations_flow_{db_kind}"), + read_to_string(tree_fs.root.join("myapp").join("schema_dump.json")).unwrap() + ); } diff --git a/loco-gen/tests/snapshots/db__migrations_flow_postgres.snap b/loco-gen/tests/snapshots/db__migrations_flow_postgres.snap new file mode 100644 index 000000000..48bdaa16c --- /dev/null +++ b/loco-gen/tests/snapshots/db__migrations_flow_postgres.snap @@ -0,0 +1,836 @@ +--- +source: loco-gen/tests/db.rs +expression: "read_to_string(tree_fs.root.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" +--- +[ + { + "column": "created_at", + "table": "actor_movies", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "actor_movies", + "type": "timestamp with time zone" + }, + { + "column": "actor_id", + "table": "actor_movies", + "type": "integer" + }, + { + "column": "movie_id", + "table": "actor_movies", + "type": "integer" + }, + { + "column": "created_at", + "table": "actors", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "actors", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "actors", + "type": "integer" + }, + { + "column": "foobar", + "table": "actors", + "type": "character varying" + }, + { + "column": "created_at", + "table": "awards", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "awards", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "awards", + "type": "integer" + }, + { + "column": "name", + "table": "awards", + "type": "character varying" + }, + { + "column": "actor_id", + "table": "awards", + "type": "integer" + }, + { + "column": "created_at", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "movies", + "type": "integer" + }, + { + "column": "uuid_uniq", + "table": "movies", + "type": "uuid" + }, + { + "column": "uuid", + "table": "movies", + "type": "uuid" + }, + { + "column": "uuid_nonull", + "table": "movies", + "type": "uuid" + }, + { + "column": "string", + "table": "movies", + "type": "character varying" + }, + { + "column": "string_nonull", + "table": "movies", + "type": "character varying" + }, + { + "column": "string_uniq", + "table": "movies", + "type": "character varying" + }, + { + "column": "text", + "table": "movies", + "type": "text" + }, + { + "column": "text_nonull", + "table": "movies", + "type": "text" + }, + { + "column": "text_uniq", + "table": "movies", + "type": "text" + }, + { + "column": "small_unsigned", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_unsigned_nonull", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_unsigned_uniq", + "table": "movies", + "type": "smallint" + }, + { + "column": "big_unsigned", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_unsigned_nonull", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_unsigned_uniq", + "table": "movies", + "type": "bigint" + }, + { + "column": "small_int", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_int_nonull", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_int_uniq", + "table": "movies", + "type": "smallint" + }, + { + "column": "int", + "table": "movies", + "type": "integer" + }, + { + "column": "int_nonull", + "table": "movies", + "type": "integer" + }, + { + "column": "int_uniq", + "table": "movies", + "type": "integer" + }, + { + "column": "big_int", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_int_nonull", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_int_uniq", + "table": "movies", + "type": "bigint" + }, + { + "column": "float", + "table": "movies", + "type": "real" + }, + { + "column": "float_nonull", + "table": "movies", + "type": "real" + }, + { + "column": "float_uniq", + "table": "movies", + "type": "real" + }, + { + "column": "double", + "table": "movies", + "type": "double precision" + }, + { + "column": "double_nonull", + "table": "movies", + "type": "double precision" + }, + { + "column": "double_uniq", + "table": "movies", + "type": "double precision" + }, + { + "column": "decimal", + "table": "movies", + "type": "numeric" + }, + { + "column": "decimal_nonull", + "table": "movies", + "type": "numeric" + }, + { + "column": "decimal_uniq", + "table": "movies", + "type": "numeric" + }, + { + "column": "bool", + "table": "movies", + "type": "boolean" + }, + { + "column": "bool_nonull", + "table": "movies", + "type": "boolean" + }, + { + "column": "tstz", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "tstz_nonull", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "date", + "table": "movies", + "type": "date" + }, + { + "column": "date_nonull", + "table": "movies", + "type": "date" + }, + { + "column": "date_uniq", + "table": "movies", + "type": "date" + }, + { + "column": "date_time", + "table": "movies", + "type": "timestamp without time zone" + }, + { + "column": "date_time_nonull", + "table": "movies", + "type": "timestamp without time zone" + }, + { + "column": "date_time_uniq", + "table": "movies", + "type": "timestamp without time zone" + }, + { + "column": "json", + "table": "movies", + "type": "json" + }, + { + "column": "json_nonull", + "table": "movies", + "type": "json" + }, + { + "column": "jsonb", + "table": "movies", + "type": "jsonb" + }, + { + "column": "jsonb_nonull", + "table": "movies", + "type": "jsonb" + }, + { + "column": "jsonb_uniq", + "table": "movies", + "type": "jsonb" + }, + { + "column": "blob", + "table": "movies", + "type": "bytea" + }, + { + "column": "blob_nonull", + "table": "movies", + "type": "bytea" + }, + { + "column": "blob_uniq", + "table": "movies", + "type": "bytea" + }, + { + "column": "money", + "table": "movies", + "type": "money" + }, + { + "column": "money_nonull", + "table": "movies", + "type": "money" + }, + { + "column": "money_uniq", + "table": "movies", + "type": "money" + }, + { + "column": "unsigned_nonull", + "table": "movies", + "type": "integer" + }, + { + "column": "unsigned", + "table": "movies", + "type": "integer" + }, + { + "column": "unsigned_uniq", + "table": "movies", + "type": "integer" + }, + { + "column": "age", + "table": "movies", + "type": "numeric" + }, + { + "column": "age_nonull", + "table": "movies", + "type": "numeric" + }, + { + "column": "array_string", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_float", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_int", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_double", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_bool", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "playlist_id", + "table": "movies", + "type": "integer" + }, + { + "column": "rating", + "table": "movies", + "type": "integer" + }, + { + "column": "created_at", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "playlists", + "type": "integer" + }, + { + "column": "uuid_uniq", + "table": "playlists", + "type": "uuid" + }, + { + "column": "uuid", + "table": "playlists", + "type": "uuid" + }, + { + "column": "uuid_nonull", + "table": "playlists", + "type": "uuid" + }, + { + "column": "string", + "table": "playlists", + "type": "character varying" + }, + { + "column": "string_nonull", + "table": "playlists", + "type": "character varying" + }, + { + "column": "string_uniq", + "table": "playlists", + "type": "character varying" + }, + { + "column": "text", + "table": "playlists", + "type": "text" + }, + { + "column": "text_nonull", + "table": "playlists", + "type": "text" + }, + { + "column": "text_uniq", + "table": "playlists", + "type": "text" + }, + { + "column": "small_unsigned", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_unsigned_nonull", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_unsigned_uniq", + "table": "playlists", + "type": "smallint" + }, + { + "column": "big_unsigned", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_unsigned_nonull", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_unsigned_uniq", + "table": "playlists", + "type": "bigint" + }, + { + "column": "small_int", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_int_nonull", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_int_uniq", + "table": "playlists", + "type": "smallint" + }, + { + "column": "int", + "table": "playlists", + "type": "integer" + }, + { + "column": "int_nonull", + "table": "playlists", + "type": "integer" + }, + { + "column": "int_uniq", + "table": "playlists", + "type": "integer" + }, + { + "column": "big_int", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_int_nonull", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_int_uniq", + "table": "playlists", + "type": "bigint" + }, + { + "column": "float", + "table": "playlists", + "type": "real" + }, + { + "column": "float_nonull", + "table": "playlists", + "type": "real" + }, + { + "column": "float_uniq", + "table": "playlists", + "type": "real" + }, + { + "column": "double", + "table": "playlists", + "type": "double precision" + }, + { + "column": "double_nonull", + "table": "playlists", + "type": "double precision" + }, + { + "column": "double_uniq", + "table": "playlists", + "type": "double precision" + }, + { + "column": "decimal", + "table": "playlists", + "type": "numeric" + }, + { + "column": "decimal_nonull", + "table": "playlists", + "type": "numeric" + }, + { + "column": "decimal_uniq", + "table": "playlists", + "type": "numeric" + }, + { + "column": "bool", + "table": "playlists", + "type": "boolean" + }, + { + "column": "bool_nonull", + "table": "playlists", + "type": "boolean" + }, + { + "column": "tstz", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "tstz_nonull", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "date", + "table": "playlists", + "type": "date" + }, + { + "column": "date_nonull", + "table": "playlists", + "type": "date" + }, + { + "column": "date_uniq", + "table": "playlists", + "type": "date" + }, + { + "column": "date_time", + "table": "playlists", + "type": "timestamp without time zone" + }, + { + "column": "date_time_nonull", + "table": "playlists", + "type": "timestamp without time zone" + }, + { + "column": "date_time_uniq", + "table": "playlists", + "type": "timestamp without time zone" + }, + { + "column": "json", + "table": "playlists", + "type": "json" + }, + { + "column": "json_nonull", + "table": "playlists", + "type": "json" + }, + { + "column": "jsonb", + "table": "playlists", + "type": "jsonb" + }, + { + "column": "jsonb_nonull", + "table": "playlists", + "type": "jsonb" + }, + { + "column": "jsonb_uniq", + "table": "playlists", + "type": "jsonb" + }, + { + "column": "blob", + "table": "playlists", + "type": "bytea" + }, + { + "column": "blob_nonull", + "table": "playlists", + "type": "bytea" + }, + { + "column": "blob_uniq", + "table": "playlists", + "type": "bytea" + }, + { + "column": "money", + "table": "playlists", + "type": "money" + }, + { + "column": "money_nonull", + "table": "playlists", + "type": "money" + }, + { + "column": "money_uniq", + "table": "playlists", + "type": "money" + }, + { + "column": "unsigned_nonull", + "table": "playlists", + "type": "integer" + }, + { + "column": "unsigned", + "table": "playlists", + "type": "integer" + }, + { + "column": "unsigned_uniq", + "table": "playlists", + "type": "integer" + }, + { + "column": "age", + "table": "playlists", + "type": "numeric" + }, + { + "column": "age_nonull", + "table": "playlists", + "type": "numeric" + }, + { + "column": "array_string", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_float", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_int", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_double", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_bool", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "version", + "table": "seaql_migrations", + "type": "character varying" + }, + { + "column": "applied_at", + "table": "seaql_migrations", + "type": "bigint" + }, + { + "column": "created_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "users", + "type": "integer" + }, + { + "column": "pid", + "table": "users", + "type": "uuid" + }, + { + "column": "email", + "table": "users", + "type": "character varying" + }, + { + "column": "password", + "table": "users", + "type": "character varying" + }, + { + "column": "api_key", + "table": "users", + "type": "character varying" + }, + { + "column": "name", + "table": "users", + "type": "character varying" + }, + { + "column": "reset_token", + "table": "users", + "type": "character varying" + }, + { + "column": "reset_sent_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "email_verification_token", + "table": "users", + "type": "character varying" + }, + { + "column": "email_verification_sent_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "email_verified_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "magic_link_token", + "table": "users", + "type": "character varying" + }, + { + "column": "magic_link_expiration", + "table": "users", + "type": "timestamp with time zone" + } +] diff --git a/loco-gen/tests/snapshots/db__migrations_flow.snap b/loco-gen/tests/snapshots/db__migrations_flow_sqlite.snap similarity index 98% rename from loco-gen/tests/snapshots/db__migrations_flow.snap rename to loco-gen/tests/snapshots/db__migrations_flow_sqlite.snap index b980bd13d..5df2a0d4d 100644 --- a/loco-gen/tests/snapshots/db__migrations_flow.snap +++ b/loco-gen/tests/snapshots/db__migrations_flow_sqlite.snap @@ -1,6 +1,6 @@ --- source: loco-gen/tests/db.rs -expression: "read_to_string(test_dir.path.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" +expression: "read_to_string(tree_fs.root.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" --- [ { diff --git a/loco-gen/tests/snapshots/r#mod__db__migrations_flow_postgres.snap b/loco-gen/tests/snapshots/r#mod__db__migrations_flow_postgres.snap new file mode 100644 index 000000000..48bdaa16c --- /dev/null +++ b/loco-gen/tests/snapshots/r#mod__db__migrations_flow_postgres.snap @@ -0,0 +1,836 @@ +--- +source: loco-gen/tests/db.rs +expression: "read_to_string(tree_fs.root.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" +--- +[ + { + "column": "created_at", + "table": "actor_movies", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "actor_movies", + "type": "timestamp with time zone" + }, + { + "column": "actor_id", + "table": "actor_movies", + "type": "integer" + }, + { + "column": "movie_id", + "table": "actor_movies", + "type": "integer" + }, + { + "column": "created_at", + "table": "actors", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "actors", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "actors", + "type": "integer" + }, + { + "column": "foobar", + "table": "actors", + "type": "character varying" + }, + { + "column": "created_at", + "table": "awards", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "awards", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "awards", + "type": "integer" + }, + { + "column": "name", + "table": "awards", + "type": "character varying" + }, + { + "column": "actor_id", + "table": "awards", + "type": "integer" + }, + { + "column": "created_at", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "movies", + "type": "integer" + }, + { + "column": "uuid_uniq", + "table": "movies", + "type": "uuid" + }, + { + "column": "uuid", + "table": "movies", + "type": "uuid" + }, + { + "column": "uuid_nonull", + "table": "movies", + "type": "uuid" + }, + { + "column": "string", + "table": "movies", + "type": "character varying" + }, + { + "column": "string_nonull", + "table": "movies", + "type": "character varying" + }, + { + "column": "string_uniq", + "table": "movies", + "type": "character varying" + }, + { + "column": "text", + "table": "movies", + "type": "text" + }, + { + "column": "text_nonull", + "table": "movies", + "type": "text" + }, + { + "column": "text_uniq", + "table": "movies", + "type": "text" + }, + { + "column": "small_unsigned", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_unsigned_nonull", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_unsigned_uniq", + "table": "movies", + "type": "smallint" + }, + { + "column": "big_unsigned", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_unsigned_nonull", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_unsigned_uniq", + "table": "movies", + "type": "bigint" + }, + { + "column": "small_int", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_int_nonull", + "table": "movies", + "type": "smallint" + }, + { + "column": "small_int_uniq", + "table": "movies", + "type": "smallint" + }, + { + "column": "int", + "table": "movies", + "type": "integer" + }, + { + "column": "int_nonull", + "table": "movies", + "type": "integer" + }, + { + "column": "int_uniq", + "table": "movies", + "type": "integer" + }, + { + "column": "big_int", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_int_nonull", + "table": "movies", + "type": "bigint" + }, + { + "column": "big_int_uniq", + "table": "movies", + "type": "bigint" + }, + { + "column": "float", + "table": "movies", + "type": "real" + }, + { + "column": "float_nonull", + "table": "movies", + "type": "real" + }, + { + "column": "float_uniq", + "table": "movies", + "type": "real" + }, + { + "column": "double", + "table": "movies", + "type": "double precision" + }, + { + "column": "double_nonull", + "table": "movies", + "type": "double precision" + }, + { + "column": "double_uniq", + "table": "movies", + "type": "double precision" + }, + { + "column": "decimal", + "table": "movies", + "type": "numeric" + }, + { + "column": "decimal_nonull", + "table": "movies", + "type": "numeric" + }, + { + "column": "decimal_uniq", + "table": "movies", + "type": "numeric" + }, + { + "column": "bool", + "table": "movies", + "type": "boolean" + }, + { + "column": "bool_nonull", + "table": "movies", + "type": "boolean" + }, + { + "column": "tstz", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "tstz_nonull", + "table": "movies", + "type": "timestamp with time zone" + }, + { + "column": "date", + "table": "movies", + "type": "date" + }, + { + "column": "date_nonull", + "table": "movies", + "type": "date" + }, + { + "column": "date_uniq", + "table": "movies", + "type": "date" + }, + { + "column": "date_time", + "table": "movies", + "type": "timestamp without time zone" + }, + { + "column": "date_time_nonull", + "table": "movies", + "type": "timestamp without time zone" + }, + { + "column": "date_time_uniq", + "table": "movies", + "type": "timestamp without time zone" + }, + { + "column": "json", + "table": "movies", + "type": "json" + }, + { + "column": "json_nonull", + "table": "movies", + "type": "json" + }, + { + "column": "jsonb", + "table": "movies", + "type": "jsonb" + }, + { + "column": "jsonb_nonull", + "table": "movies", + "type": "jsonb" + }, + { + "column": "jsonb_uniq", + "table": "movies", + "type": "jsonb" + }, + { + "column": "blob", + "table": "movies", + "type": "bytea" + }, + { + "column": "blob_nonull", + "table": "movies", + "type": "bytea" + }, + { + "column": "blob_uniq", + "table": "movies", + "type": "bytea" + }, + { + "column": "money", + "table": "movies", + "type": "money" + }, + { + "column": "money_nonull", + "table": "movies", + "type": "money" + }, + { + "column": "money_uniq", + "table": "movies", + "type": "money" + }, + { + "column": "unsigned_nonull", + "table": "movies", + "type": "integer" + }, + { + "column": "unsigned", + "table": "movies", + "type": "integer" + }, + { + "column": "unsigned_uniq", + "table": "movies", + "type": "integer" + }, + { + "column": "age", + "table": "movies", + "type": "numeric" + }, + { + "column": "age_nonull", + "table": "movies", + "type": "numeric" + }, + { + "column": "array_string", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_float", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_int", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_double", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "array_bool", + "table": "movies", + "type": "ARRAY" + }, + { + "column": "playlist_id", + "table": "movies", + "type": "integer" + }, + { + "column": "rating", + "table": "movies", + "type": "integer" + }, + { + "column": "created_at", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "playlists", + "type": "integer" + }, + { + "column": "uuid_uniq", + "table": "playlists", + "type": "uuid" + }, + { + "column": "uuid", + "table": "playlists", + "type": "uuid" + }, + { + "column": "uuid_nonull", + "table": "playlists", + "type": "uuid" + }, + { + "column": "string", + "table": "playlists", + "type": "character varying" + }, + { + "column": "string_nonull", + "table": "playlists", + "type": "character varying" + }, + { + "column": "string_uniq", + "table": "playlists", + "type": "character varying" + }, + { + "column": "text", + "table": "playlists", + "type": "text" + }, + { + "column": "text_nonull", + "table": "playlists", + "type": "text" + }, + { + "column": "text_uniq", + "table": "playlists", + "type": "text" + }, + { + "column": "small_unsigned", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_unsigned_nonull", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_unsigned_uniq", + "table": "playlists", + "type": "smallint" + }, + { + "column": "big_unsigned", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_unsigned_nonull", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_unsigned_uniq", + "table": "playlists", + "type": "bigint" + }, + { + "column": "small_int", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_int_nonull", + "table": "playlists", + "type": "smallint" + }, + { + "column": "small_int_uniq", + "table": "playlists", + "type": "smallint" + }, + { + "column": "int", + "table": "playlists", + "type": "integer" + }, + { + "column": "int_nonull", + "table": "playlists", + "type": "integer" + }, + { + "column": "int_uniq", + "table": "playlists", + "type": "integer" + }, + { + "column": "big_int", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_int_nonull", + "table": "playlists", + "type": "bigint" + }, + { + "column": "big_int_uniq", + "table": "playlists", + "type": "bigint" + }, + { + "column": "float", + "table": "playlists", + "type": "real" + }, + { + "column": "float_nonull", + "table": "playlists", + "type": "real" + }, + { + "column": "float_uniq", + "table": "playlists", + "type": "real" + }, + { + "column": "double", + "table": "playlists", + "type": "double precision" + }, + { + "column": "double_nonull", + "table": "playlists", + "type": "double precision" + }, + { + "column": "double_uniq", + "table": "playlists", + "type": "double precision" + }, + { + "column": "decimal", + "table": "playlists", + "type": "numeric" + }, + { + "column": "decimal_nonull", + "table": "playlists", + "type": "numeric" + }, + { + "column": "decimal_uniq", + "table": "playlists", + "type": "numeric" + }, + { + "column": "bool", + "table": "playlists", + "type": "boolean" + }, + { + "column": "bool_nonull", + "table": "playlists", + "type": "boolean" + }, + { + "column": "tstz", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "tstz_nonull", + "table": "playlists", + "type": "timestamp with time zone" + }, + { + "column": "date", + "table": "playlists", + "type": "date" + }, + { + "column": "date_nonull", + "table": "playlists", + "type": "date" + }, + { + "column": "date_uniq", + "table": "playlists", + "type": "date" + }, + { + "column": "date_time", + "table": "playlists", + "type": "timestamp without time zone" + }, + { + "column": "date_time_nonull", + "table": "playlists", + "type": "timestamp without time zone" + }, + { + "column": "date_time_uniq", + "table": "playlists", + "type": "timestamp without time zone" + }, + { + "column": "json", + "table": "playlists", + "type": "json" + }, + { + "column": "json_nonull", + "table": "playlists", + "type": "json" + }, + { + "column": "jsonb", + "table": "playlists", + "type": "jsonb" + }, + { + "column": "jsonb_nonull", + "table": "playlists", + "type": "jsonb" + }, + { + "column": "jsonb_uniq", + "table": "playlists", + "type": "jsonb" + }, + { + "column": "blob", + "table": "playlists", + "type": "bytea" + }, + { + "column": "blob_nonull", + "table": "playlists", + "type": "bytea" + }, + { + "column": "blob_uniq", + "table": "playlists", + "type": "bytea" + }, + { + "column": "money", + "table": "playlists", + "type": "money" + }, + { + "column": "money_nonull", + "table": "playlists", + "type": "money" + }, + { + "column": "money_uniq", + "table": "playlists", + "type": "money" + }, + { + "column": "unsigned_nonull", + "table": "playlists", + "type": "integer" + }, + { + "column": "unsigned", + "table": "playlists", + "type": "integer" + }, + { + "column": "unsigned_uniq", + "table": "playlists", + "type": "integer" + }, + { + "column": "age", + "table": "playlists", + "type": "numeric" + }, + { + "column": "age_nonull", + "table": "playlists", + "type": "numeric" + }, + { + "column": "array_string", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_float", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_int", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_double", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "array_bool", + "table": "playlists", + "type": "ARRAY" + }, + { + "column": "version", + "table": "seaql_migrations", + "type": "character varying" + }, + { + "column": "applied_at", + "table": "seaql_migrations", + "type": "bigint" + }, + { + "column": "created_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "updated_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "id", + "table": "users", + "type": "integer" + }, + { + "column": "pid", + "table": "users", + "type": "uuid" + }, + { + "column": "email", + "table": "users", + "type": "character varying" + }, + { + "column": "password", + "table": "users", + "type": "character varying" + }, + { + "column": "api_key", + "table": "users", + "type": "character varying" + }, + { + "column": "name", + "table": "users", + "type": "character varying" + }, + { + "column": "reset_token", + "table": "users", + "type": "character varying" + }, + { + "column": "reset_sent_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "email_verification_token", + "table": "users", + "type": "character varying" + }, + { + "column": "email_verification_sent_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "email_verified_at", + "table": "users", + "type": "timestamp with time zone" + }, + { + "column": "magic_link_token", + "table": "users", + "type": "character varying" + }, + { + "column": "magic_link_expiration", + "table": "users", + "type": "timestamp with time zone" + } +] diff --git a/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap b/loco-gen/tests/snapshots/r#mod__db__migrations_flow_sqlite.snap similarity index 98% rename from loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap rename to loco-gen/tests/snapshots/r#mod__db__migrations_flow_sqlite.snap index b980bd13d..5df2a0d4d 100644 --- a/loco-gen/tests/snapshots/r#mod__db__migrations_flow.snap +++ b/loco-gen/tests/snapshots/r#mod__db__migrations_flow_sqlite.snap @@ -1,6 +1,6 @@ --- source: loco-gen/tests/db.rs -expression: "read_to_string(test_dir.path.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" +expression: "read_to_string(tree_fs.root.join(\"myapp\").join(\"schema_dump.json\")).unwrap()" --- [ { diff --git a/loco-new/tests/wizard/new.rs b/loco-new/tests/wizard/new.rs index 32b9c4cbd..e8669ee2c 100644 --- a/loco-new/tests/wizard/new.rs +++ b/loco-new/tests/wizard/new.rs @@ -163,23 +163,25 @@ fn test_combination( } tester.run_generate(&vec!["model", "movies", "title:string", "user:references"]); - // Generate HTMX Scaffold - tester.run_generate(&vec![ - "scaffold", - "movies_htmx", - "title:string", - "user:references", - "--htmx", - ]); - - // Generate HTML Scaffold - tester.run_generate(&vec![ - "scaffold", - "movies_html", - "title:string", - "user:references", - "--html", - ]); + if asset.enable() { + // Generate HTMX Scaffold + tester.run_generate(&vec![ + "scaffold", + "movies_htmx", + "title:string", + "user:references", + "--htmx", + ]); + + // Generate HTML Scaffold + tester.run_generate(&vec![ + "scaffold", + "movies_html", + "title:string", + "user:references", + "--html", + ]); + } // Generate API Scaffold tester.run_generate(&vec![ From 861dd3f05f72267dbb0ac18a5619925019e6dd3e Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Sun, 26 Jan 2025 19:49:20 +0200 Subject: [PATCH 25/26] unnecessary html classes --- loco-gen/src/templates/scaffold/html/base.t | 2 -- loco-gen/src/templates/scaffold/htmx/base.t | 22 +++++++++------------ loco-gen/tests/mod.rs | 1 - 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/loco-gen/src/templates/scaffold/html/base.t b/loco-gen/src/templates/scaffold/html/base.t index f5461cb9d..37d9e46dc 100644 --- a/loco-gen/src/templates/scaffold/html/base.t +++ b/loco-gen/src/templates/scaffold/html/base.t @@ -19,7 +19,6 @@ message: "Base template was added successfully."
-

@@ -29,7 +28,6 @@ message: "Base template was added successfully." {% endblock content %}{% endraw %}

-
{% raw %}{% block js %} diff --git a/loco-gen/src/templates/scaffold/htmx/base.t b/loco-gen/src/templates/scaffold/htmx/base.t index 4651c3e13..547c0f81c 100644 --- a/loco-gen/src/templates/scaffold/htmx/base.t +++ b/loco-gen/src/templates/scaffold/htmx/base.t @@ -21,19 +21,15 @@ message: "Base template was added successfully."
-
-
-
-

- {% raw %}{% block page_title %}{% endblock page_title %}{% endraw %} -

- {% raw %}{% block content %} - {% endblock content %}{% endraw %} -
-
- -
- +
+
+

+ {% raw %}{% block page_title %}{% endblock page_title %}{% endraw %} +

+ {% raw %}{% block content %} + {% endblock content %}{% endraw %} +
+
{% raw %}{% block js %} diff --git a/loco-gen/tests/mod.rs b/loco-gen/tests/mod.rs index 8a0e2eab5..6ccfc578e 100644 --- a/loco-gen/tests/mod.rs +++ b/loco-gen/tests/mod.rs @@ -1,2 +1 @@ -mod db; mod templates; From 3f1122cb682e388b31a7c24ddd92cbb3024bf4e2 Mon Sep 17 00:00:00 2001 From: Elad Kaplan Date: Mon, 27 Jan 2025 07:40:04 +0200 Subject: [PATCH 26/26] add db to loco-gen crate --- .github/workflows/loco-gen-ci.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/loco-gen-ci.yml b/.github/workflows/loco-gen-ci.yml index b170dedbb..71f495953 100644 --- a/.github/workflows/loco-gen-ci.yml +++ b/.github/workflows/loco-gen-ci.yml @@ -52,6 +52,21 @@ jobs: permissions: contents: read + services: + postgres: + image: postgres + env: + POSTGRES_DB: postgres_test + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + ports: + - "5432:5432" + # Set health checks to wait until postgres has started + options: --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + steps: - name: Checkout the code uses: actions/checkout@v4 @@ -71,3 +86,4 @@ jobs: run: cargo test --all-features env: LOCO_DEV_MODE_PATH: ${{ github.workspace }} + DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres_test