diff --git a/.sqlxrc.sample.json b/.sqlxrc.sample.json index 9abaffa4..ee7909cf 100644 --- a/.sqlxrc.sample.json +++ b/.sqlxrc.sample.json @@ -1,5 +1,6 @@ { "generateTypes": { + "enabled": true, "columnNamingConvention": "camel", "convertToCamelCaseColumnName": false }, diff --git a/playpen/db/mysql_migration.sql b/playpen/db/mysql_migration.sql index 396078eb..a1666860 100644 --- a/playpen/db/mysql_migration.sql +++ b/playpen/db/mysql_migration.sql @@ -11,6 +11,7 @@ CREATE TABLE items ( time_takes_to_cook INTEGER NOT NULL, table_id INTEGER NOT NULL, points SMALLINT NOT NULL, + description VARCHAR(255) NULL, FOREIGN KEY (table_id) REFERENCES tables (id), PRIMARY KEY (id) ); diff --git a/playpen/db/mysql_migration_5_6.sql b/playpen/db/mysql_migration_5_6.sql index e216f181..f5a71018 100644 --- a/playpen/db/mysql_migration_5_6.sql +++ b/playpen/db/mysql_migration_5_6.sql @@ -11,6 +11,7 @@ CREATE TABLE items ( time_takes_to_cook INTEGER NOT NULL, table_id INTEGER NOT NULL, points SMALLINT NOT NULL, + description VARCHAR(255) NULL, FOREIGN KEY (table_id) REFERENCES tables (id), PRIMARY KEY (id) ); diff --git a/playpen/db/postgres_migration.sql b/playpen/db/postgres_migration.sql index d84d161b..dd78f06d 100644 --- a/playpen/db/postgres_migration.sql +++ b/playpen/db/postgres_migration.sql @@ -17,6 +17,7 @@ CREATE TABLE postgres.public.items ( time_takes_to_cook INTEGER NOT NULL, table_id INTEGER NOT NULL, points SMALLINT NOT NULL, + description VARCHAR(255) NULL, FOREIGN KEY (table_id) REFERENCES public.tables (id), PRIMARY KEY (id) ); diff --git a/src/main.rs b/src/main.rs index e397f7d3..abb50f44 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,10 @@ clippy::borrow_deref_ref, clippy::clone_on_copy, clippy::extra_unused_lifetimes, - clippy::explicit_auto_deref + clippy::explicit_auto_deref, + clippy::print_stdout, + clippy::print_stderr, + clippy::println_empty_string )] #![allow(clippy::ptr_arg)] mod common; @@ -60,6 +63,7 @@ async fn main() -> Result<()> { for file_path in files.iter() { let (sqls, handler) = parse_source(file_path)?; let failed = execute(&sqls, &handler).await?; + #[allow(clippy::print_stderr)] if failed { eprint!("SQLs failed to compile!"); std::process::exit(1) diff --git a/src/ts_generator/sql_parser/expressions/translate_expr.rs b/src/ts_generator/sql_parser/expressions/translate_expr.rs index cf80ea7a..bdfe414e 100644 --- a/src/ts_generator/sql_parser/expressions/translate_expr.rs +++ b/src/ts_generator/sql_parser/expressions/translate_expr.rs @@ -101,7 +101,7 @@ pub async fn get_sql_query_param( single_table_name: &Option<&str>, table_with_joins: &Option>, db_conn: &DBConn, -) -> Option<(TsFieldType, Option)> { +) -> Option<(TsFieldType, bool, Option)> { let table_name: Option; if table_with_joins.is_some() { @@ -132,7 +132,7 @@ pub async fn get_sql_query_param( let column = columns .get(column_name.as_str()) .unwrap_or_else(|| panic!("Failed to find the column from the table schema of {:?}", table_name)); - Some((column.field_type.to_owned(), Some(expr_placeholder))) + Some((column.field_type.to_owned(), column.is_nullable, Some(expr_placeholder))) } _ => None, } @@ -168,6 +168,7 @@ pub async fn translate_expr( Some(field_name), &[field.field_type.to_owned()], is_selection, + field.is_nullable, expr_for_logging, )? } @@ -202,6 +203,7 @@ pub async fn translate_expr( Some(key_name), &[field.field_type.to_owned()], is_selection, + field.is_nullable, expr_for_logging, )?; } @@ -213,8 +215,8 @@ pub async fn translate_expr( ///////////////////// Expr::BinaryOp { left, op: _, right } => { let param = get_sql_query_param(left, right, single_table_name, table_with_joins, db_conn).await; - if let Some((value, index)) = param { - let _ = ts_query.insert_param(&value, &index); + if let Some((value, is_nullable, index)) = param { + let _ = ts_query.insert_param(&value, &is_nullable, &index); Ok(()) } else { translate_expr( @@ -241,7 +243,7 @@ pub async fn translate_expr( } } Expr::InList { expr, list, negated: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, expr_for_logging)?; + ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, false, expr_for_logging)?; // If the list is just a single `(?)`, then we should return the dynamic // If the list contains multiple `(?, ?...)` then we should return a fixed length array if list.len() == 1 { @@ -257,10 +259,10 @@ pub async fn translate_expr( ) .await; - if let Some((value, index)) = result { + if let Some((value, is_nullable, index)) = result { let array_item = TsFieldType::Array(Box::new(value)); - let _ = ts_query.insert_param(&array_item, &index); + let _ = ts_query.insert_param(&array_item, &false, &index); return Ok(()); } else { return Ok(()); @@ -285,12 +287,12 @@ pub async fn translate_expr( } => { let low = get_sql_query_param(expr, low, single_table_name, table_with_joins, db_conn).await; let high = get_sql_query_param(expr, high, single_table_name, table_with_joins, db_conn).await; - if let Some((value, placeholder)) = low { - ts_query.insert_param(&value, &placeholder)?; + if let Some((value, is_nullable, placeholder)) = low { + ts_query.insert_param(&value, &is_nullable, &placeholder)?; } - if let Some((value, placeholder)) = high { - ts_query.insert_param(&value, &placeholder)?; + if let Some((value, is_nullable, placeholder)) = high { + ts_query.insert_param(&value, &is_nullable, &placeholder)?; } Ok(()) } @@ -331,22 +333,22 @@ pub async fn translate_expr( let ts_field_type = translate_value(placeholder); if let Some(ts_field_type) = ts_field_type { - return ts_query.insert_result(alias, &[ts_field_type], is_selection, expr_for_logging); + return ts_query.insert_result(alias, &[ts_field_type], is_selection, false, expr_for_logging); } - ts_query.insert_param(&TsFieldType::Boolean, &Some(placeholder.to_string())) + ts_query.insert_param(&TsFieldType::Boolean, &false, &Some(placeholder.to_string())) } Expr::JsonAccess { left: _, operator: _, right: _, } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging)?; - ts_query.insert_param(&TsFieldType::Any, &None) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&TsFieldType::Any, &false, &None) } Expr::IsNotDistinctFrom(_, placeholder) | Expr::IsDistinctFrom(_, placeholder) => { // IsDistinctFrom and IsNotDistinctFrom are the same and can have a placeholder - ts_query.insert_param(&TsFieldType::String, &Some(placeholder.to_string()))?; - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_param(&TsFieldType::String, &false, &Some(placeholder.to_string()))?; + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } Expr::SimilarTo { negated: _, @@ -367,7 +369,7 @@ pub async fn translate_expr( escape_char: _, } => { // If the pattern has a placeholder, then we should append the param to ts_query - ts_query.insert_param(&TsFieldType::String, &Some(pattern.to_string())) + ts_query.insert_param(&TsFieldType::String, &false, &Some(pattern.to_string())) } Expr::TryCast { expr, @@ -385,28 +387,28 @@ pub async fn translate_expr( format: _, } => { let data_type = translate_data_type(data_type); - ts_query.insert_result(alias, &[data_type.clone()], is_selection, expr_for_logging)?; - ts_query.insert_param(&data_type, &Some(expr.to_string()))?; + ts_query.insert_result(alias, &[data_type.clone()], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&data_type, &false, &Some(expr.to_string()))?; Ok(()) } Expr::AtTimeZone { timestamp, time_zone } => { - ts_query.insert_result(alias, &[TsFieldType::Date], is_selection, expr_for_logging)?; - ts_query.insert_param(&TsFieldType::String, &Some(timestamp.to_string()))?; - ts_query.insert_param(&TsFieldType::String, &Some(time_zone.to_string()))?; + ts_query.insert_result(alias, &[TsFieldType::Date], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(timestamp.to_string()))?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(time_zone.to_string()))?; Ok(()) } Expr::Extract { field, expr } => { - ts_query.insert_result(alias, &[TsFieldType::Date], is_selection, expr_for_logging)?; - ts_query.insert_param(&TsFieldType::String, &Some(field.to_string()))?; - ts_query.insert_param(&TsFieldType::String, &Some(expr.to_string()))?; + ts_query.insert_result(alias, &[TsFieldType::Date], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(field.to_string()))?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(expr.to_string()))?; Ok(()) } Expr::Floor { expr, field: _ } | Expr::Ceil { expr, field: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging)?; - ts_query.insert_param(&TsFieldType::Number, &Some(expr.to_string())) + ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&TsFieldType::Number, &false, &Some(expr.to_string())) } Expr::Position { expr: _, r#in: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, false, expr_for_logging) } Expr::Substring { expr, @@ -414,8 +416,8 @@ pub async fn translate_expr( substring_for: _, special: _, } => { - ts_query.insert_result(alias, &[TsFieldType::String], is_selection, expr_for_logging)?; - ts_query.insert_param(&TsFieldType::String, &Some(expr.to_string())) + ts_query.insert_result(alias, &[TsFieldType::String], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(expr.to_string())) } Expr::Trim { expr, @@ -423,8 +425,8 @@ pub async fn translate_expr( trim_what: _, trim_characters: _, } => { - ts_query.insert_result(alias, &[TsFieldType::String], is_selection, expr_for_logging)?; - ts_query.insert_param(&TsFieldType::String, &Some(expr.to_string())) + ts_query.insert_result(alias, &[TsFieldType::String], is_selection, false, expr_for_logging)?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(expr.to_string())) } Expr::Overlay { expr, @@ -432,35 +434,35 @@ pub async fn translate_expr( overlay_from, overlay_for: _, } => { - ts_query.insert_param(&TsFieldType::String, &Some(expr.to_string()))?; - ts_query.insert_param(&TsFieldType::String, &Some(overlay_what.to_string()))?; - ts_query.insert_param(&TsFieldType::Number, &Some(overlay_from.to_string()))?; - ts_query.insert_result(alias, &[TsFieldType::String], is_selection, expr_for_logging) + ts_query.insert_param(&TsFieldType::String, &false, &Some(expr.to_string()))?; + ts_query.insert_param(&TsFieldType::String, &false, &Some(overlay_what.to_string()))?; + ts_query.insert_param(&TsFieldType::Number, &false, &Some(overlay_from.to_string()))?; + ts_query.insert_result(alias, &[TsFieldType::String], is_selection, false, expr_for_logging) } Expr::Collate { expr: _, collation: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } Expr::IntroducedString { introducer: _, value: _, - } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging), + } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), Expr::TypedString { data_type: _, value: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } Expr::MapAccess { column: _, keys: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } Expr::AggregateExpressionWithFilter { expr: _, filter: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } Expr::Case { operand: _, conditions: _, results: _, else_result: _, - } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging), + } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), Expr::Exists { subquery, negated: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, expr_for_logging)?; + ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, false, expr_for_logging)?; translate_query(ts_query, &None, subquery, db_conn, alias, false).await } Expr::ListAgg(_) @@ -470,16 +472,18 @@ pub async fn translate_expr( | Expr::Rollup(_) | Expr::Tuple(_) | Expr::Array(_) - | Expr::ArraySubquery(_) => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging), + | Expr::ArraySubquery(_) => { + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) + } Expr::ArrayIndex { obj: _, indexes: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } - Expr::Interval(_) => ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging), + Expr::Interval(_) => ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, false, expr_for_logging), Expr::MatchAgainst { columns: _, match_value: _, opt_search_modifier: _, - } => ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, expr_for_logging), + } => ts_query.insert_result(alias, &[TsFieldType::Number], is_selection, false, expr_for_logging), ///////////////////// // OPERATORS ENDS // ///////////////////// @@ -487,19 +491,42 @@ pub async fn translate_expr( ///////////////////// // FUNCTIONS START // ///////////////////// - Expr::IsTrue(_query) | Expr::IsFalse(_query) | Expr::IsNull(_query) | Expr::IsNotNull(_query) => { - ts_query.insert_result(alias, &[TsFieldType::Boolean], is_selection, expr.to_string().as_str()) - } + Expr::IsTrue(_query) | Expr::IsFalse(_query) | Expr::IsNull(_query) | Expr::IsNotNull(_query) => ts_query + .insert_result( + alias, + &[TsFieldType::Boolean], + is_selection, + false, + expr.to_string().as_str(), + ), Expr::Function(function) => { let function = function.name.to_string(); let function = function.as_str(); let alias = alias.ok_or(TsGeneratorError::FunctionWithoutAliasInSelectClause(expr.to_string()))?; if is_string_function(function) { - ts_query.insert_result(Some(alias), &[TsFieldType::String], is_selection, expr_for_logging)?; + ts_query.insert_result( + Some(alias), + &[TsFieldType::String], + is_selection, + false, + expr_for_logging, + )?; } else if is_numeric_function(function) { - ts_query.insert_result(Some(alias), &[TsFieldType::Number], is_selection, expr_for_logging)?; + ts_query.insert_result( + Some(alias), + &[TsFieldType::Number], + is_selection, + false, + expr_for_logging, + )?; } else if is_date_function(function) { - ts_query.insert_result(Some(alias), &[TsFieldType::String], is_selection, expr_for_logging)?; + ts_query.insert_result( + Some(alias), + &[TsFieldType::String], + is_selection, + false, + expr_for_logging, + )?; } else { return Err(TsGeneratorError::FunctionUnknown(expr.to_string())); } @@ -510,7 +537,7 @@ pub async fn translate_expr( // FUNCTIONS END // ///////////////////// Expr::CompositeAccess { expr: _, key: _ } => { - ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging) + ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging) } Expr::Subquery(sub_query) => { // For the first layer of subquery, we consider the first field selected as the result @@ -535,8 +562,8 @@ pub async fn translate_expr( expr: _, array_expr: _, negated: _, - } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging), - _ => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, expr_for_logging), + } => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), + _ => ts_query.insert_result(alias, &[TsFieldType::Any], is_selection, false, expr_for_logging), } } @@ -559,7 +586,7 @@ pub async fn translate_assignment( let field = table_details .get(&column_name) .unwrap_or_else(|| panic!("Failed to find the column detail for {column_name}")); - let _ = ts_query.insert_param(&field.field_type, &value); + let _ = ts_query.insert_param(&field.field_type, &field.is_nullable, &value); } Ok(()) } diff --git a/src/ts_generator/sql_parser/quoted_strings.rs b/src/ts_generator/sql_parser/quoted_strings.rs index 893a9712..52e1c8d7 100644 --- a/src/ts_generator/sql_parser/quoted_strings.rs +++ b/src/ts_generator/sql_parser/quoted_strings.rs @@ -15,7 +15,7 @@ fn trim_table_name(val: &String, quote_style: &Option) -> String { pub struct DisplayIndent<'a>(pub &'a Ident); -impl<'a> fmt::Display for DisplayIndent<'a> { +impl fmt::Display for DisplayIndent<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let quote_style = &self.0.quote_style; let name = &self.0.value; @@ -26,7 +26,7 @@ impl<'a> fmt::Display for DisplayIndent<'a> { pub struct DisplayObjectName<'a>(pub &'a ObjectName); -impl<'a> fmt::Display for DisplayObjectName<'a> { +impl fmt::Display for DisplayObjectName<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let quote_style = &self.0 .0[0].quote_style; let name = &self.0 .0[0].value; @@ -37,7 +37,7 @@ impl<'a> fmt::Display for DisplayObjectName<'a> { pub struct DisplayTableAlias<'a>(pub &'a TableAlias); -impl<'a> fmt::Display for DisplayTableAlias<'a> { +impl fmt::Display for DisplayTableAlias<'_> { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let quote_style = &self.0.name.quote_style; let name = &self.0.name.value; diff --git a/src/ts_generator/sql_parser/translate_insert.rs b/src/ts_generator/sql_parser/translate_insert.rs index 28c20264..b7875a85 100644 --- a/src/ts_generator/sql_parser/translate_insert.rs +++ b/src/ts_generator/sql_parser/translate_insert.rs @@ -37,7 +37,19 @@ pub async fn translate_insert( if placeholder.is_some() { let match_col = &columns .get(column) - .unwrap_or_else(|| panic!("Matching column of idx {column} is not found while processing insert params")) + .unwrap_or_else(|| { + panic!( + r#" +Failed to process values of insert statement as column names are not provided or incorrectly specified + +Try specifying column names +``` +INSERT INTO table_name (column1, column2, column3, ...) +VALUES (value1, value2, value3, ...); +``` + "# + ) + }) .value; let field = table_details @@ -48,7 +60,7 @@ pub async fn translate_insert( // If the placeholder is `'?'`, we can process it using insert_value_params and generate nested params type ts_query.insert_value_params(&field.field_type, &(row, column), &placeholder); } else { - ts_query.insert_param(&field.field_type, &placeholder)?; + ts_query.insert_param(&field.field_type, &field.is_nullable, &placeholder)?; } } } @@ -89,7 +101,7 @@ pub async fn translate_insert_returning( let keys = table_details.keys(); for key in keys { let value = vec![table_details.get(key).unwrap().field_type.clone()]; - ts_query.insert_result(Some(key), &value, true, query_for_logging); + ts_query.insert_result(Some(key), &value, true, false, query_for_logging); } } } diff --git a/src/ts_generator/types/ts_query.rs b/src/ts_generator/types/ts_query.rs index a6696299..81d943c6 100644 --- a/src/ts_generator/types/ts_query.rs +++ b/src/ts_generator/types/ts_query.rs @@ -153,13 +153,12 @@ pub struct TsQuery { param_order: i32, // We use BTreeMap here as it's a collection that's already sorted // TODO: use usize instead - pub params: BTreeMap, + pub params: BTreeMap>, pub annotated_params: BTreeMap, // We use BTreeMap here as it's a collection that's already sorted pub insert_params: BTreeMap>, - - // Holds any annoated @param and perform replacement when generated TS types + // Holds any annotated @param and perform replacement when generated TS types pub annotated_insert_params: BTreeMap>, pub result: HashMap>, @@ -219,18 +218,23 @@ impl TsQuery { alias: Option<&str>, value: &[TsFieldType], is_selection: bool, + is_nullable: bool, expr_for_logging: &str, ) -> Result<(), TsGeneratorError> { if is_selection { if let Some(alias) = alias { let temp_alias = alias; let alias = &self.format_column_name(alias); - let value = &self + let value = &mut self .annotated_results .get(temp_alias) .cloned() .unwrap_or_else(|| value.to_vec()); + if is_nullable { + value.push(TsFieldType::Null); + } + let _ = &self.result.insert(alias.to_owned(), value.to_owned()); } else { return Err(TsGeneratorError::MissingAliasForFunctions(expr_for_logging.to_string())); @@ -282,39 +286,44 @@ impl TsQuery { /// You can only sequentially use `insert_param` with manual order or automatic order parameter /// /// This method was specifically designed with an assumption that 1 TsQuery is connected to 1 type of DB - pub fn insert_param(&mut self, value: &TsFieldType, placeholder: &Option) -> Result<(), TsGeneratorError> { + pub fn insert_param( + &mut self, + value: &TsFieldType, + is_nullable: &bool, + placeholder: &Option, + ) -> Result<(), TsGeneratorError> { if let Some(placeholder) = placeholder { - if placeholder == "?" { - let annotated_param = self.annotated_params.get(&(self.param_order as usize)); + let pg_placeholder_pattern = Regex::new(r"\$(\d+)").unwrap(); + let mut values = vec![]; - if let Some(annotated_param) = annotated_param { - self.params.insert(self.param_order, annotated_param.clone()); - } else { - self.params.insert(self.param_order, value.clone()); - } + let order = if placeholder == "?" { self.param_order += 1; + self.param_order + } else if let Some(caps) = pg_placeholder_pattern.captures(placeholder) { + caps + .get(1) + .and_then(|m| m.as_str().parse::().ok()) + .ok_or(TsGeneratorError::UnknownPlaceholder(format!( + "{placeholder} is not a valid placeholder parameter in PostgreSQL" + )))? as i32 } else { - let re = Regex::new(r"\$(\d+)").unwrap(); - let indexed_binding_params = re.captures(placeholder); - - // Only runs the code if the placeholder is an indexed binding parameter such as $1 or $2 - if let Some(indexed_binding_params) = indexed_binding_params { - let order = indexed_binding_params - .get(1) - .unwrap() - .as_str() - .parse::() - .unwrap(); - - let annotated_param = self.annotated_params.get(&(order as usize)); - - if let Some(annotated_param) = annotated_param { - self.params.insert(order, annotated_param.clone()); - } else { - self.params.insert(order, value.clone()); - } - } + // No pattern matches the provided placeholder, simply exit out of the function + return Ok(()); + } as usize; + + if let Some(annotated_param) = self.annotated_params.get(&order) { + values.push(annotated_param.clone()); + } else { + values.push(value.clone()); } + + // Add nullability if required + if *is_nullable { + values.push(TsFieldType::Null); + } + + // Insert values into the parameter map + self.params.insert(order, values); } Ok(()) } @@ -322,9 +331,7 @@ impl TsQuery { /// The method is to format SQL params extracted via translate methods /// It can work for SELECT, INSERT, DELETE and UPDATE queries fn fmt_params(&self, _: &mut fmt::Formatter<'_>) -> String { - let is_insert_query = self.insert_params.keys().len() > 0; - - if is_insert_query { + if !self.insert_params.is_empty() { return self .insert_params .values() @@ -343,15 +350,12 @@ impl TsQuery { } // Otherwise we should be processing non-insert query params - let result = &self + self .params - .to_owned() - .into_values() - .map(|x| x.to_string()) + .values() + .map(|x| x.iter().map(ToString::to_string).collect::>().join(" | ")) .collect::>() - .join(", "); - - result.to_owned() + .join(", ") } fn fmt_result(&self, _f: &mut fmt::Formatter<'_>) -> String { @@ -381,35 +385,13 @@ impl fmt::Display for TsQuery { let params_str = self.fmt_params(f); let result_str = self.fmt_result(f); - let params = format!( - r" -export type {name}Params = [{params_str}]; -" - ); - - let result = format!( - r" -export interface I{name}Result {{ - {result_str} -}}; -" - ); - - let query = format!( - r" -export interface I{name}Query {{ - params: {name}Params; - result: I{name}Result; -}}; -" - ); - - let final_code = format!( - r" -{params} -{result} -{query}" - ); + let params = format!("export type {name}Params = [{params_str}];"); + + let result = format!("export interface I{name}Result {{\n\t{result_str}\n}};"); + + let query = format!("export interface I{name}Query {{\n\tparams: {name}Params;\n\tresult: I{name}Result;\n}};"); + + let final_code = format!("{params}\n\n{result}\n\n{query}"); writeln!(f, "{}", final_code) } diff --git a/tests/demo/alias/alias.queries.ts b/tests/demo/alias/alias.queries.ts index ed0c08a0..9f163914 100644 --- a/tests/demo/alias/alias.queries.ts +++ b/tests/demo/alias/alias.queries.ts @@ -1,111 +1,76 @@ - - export type Sql1Params = []; - export interface ISql1Result { - id1: number; + id1: number; }; - export interface ISql1Query { - params: Sql1Params; - result: ISql1Result; + params: Sql1Params; + result: ISql1Result; }; - - - export type Sql2Params = []; - export interface ISql2Result { - id2: number; + id2: number; }; - export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; + params: Sql2Params; + result: ISql2Result; }; - - - export type Sql3Params = []; - export interface ISql3Result { - itemsId: number; + itemsId: number; }; - export interface ISql3Query { - params: Sql3Params; - result: ISql3Result; + params: Sql3Params; + result: ISql3Result; }; - - - export type Sql4Params = []; - export interface ISql4Result { - theCount: number; + theCount: number; }; - export interface ISql4Query { - params: Sql4Params; - result: ISql4Result; + params: Sql4Params; + result: ISql4Result; }; - - - export type Sql5Params = []; - export interface ISql5Result { - theAvg: number; + theAvg: number; }; - export interface ISql5Query { - params: Sql5Params; - result: ISql5Result; + params: Sql5Params; + result: ISql5Result; }; - - - export type Sql6Params = []; - export interface ISql6Result { - lowerVarchar: string; + lowerVarchar: string; }; - export interface ISql6Query { - params: Sql6Params; - result: ISql6Result; + params: Sql6Params; + result: ISql6Result; }; - - - export type Sql7Params = []; - export interface ISql7Result { - currentTime: string; + currentTime: string; }; - export interface ISql7Query { - params: Sql7Params; - result: ISql7Result; + params: Sql7Params; + result: ISql7Result; }; - diff --git a/tests/demo/alias/alias.snapshot.ts b/tests/demo/alias/alias.snapshot.ts index ee2bce7d..c5d953be 100644 --- a/tests/demo/alias/alias.snapshot.ts +++ b/tests/demo/alias/alias.snapshot.ts @@ -1,112 +1,77 @@ - - export type Sql1Params = []; - export interface ISql1Result { - id1: number; + id1: number; }; - export interface ISql1Query { - params: Sql1Params; - result: ISql1Result; + params: Sql1Params; + result: ISql1Result; }; - - - export type Sql2Params = []; - export interface ISql2Result { - id2: number; + id2: number; }; - export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; + params: Sql2Params; + result: ISql2Result; }; - - - export type Sql3Params = []; - export interface ISql3Result { - itemsId: number; + itemsId: number; }; - export interface ISql3Query { - params: Sql3Params; - result: ISql3Result; + params: Sql3Params; + result: ISql3Result; }; - - - export type Sql4Params = []; - export interface ISql4Result { - theCount: number; + theCount: number; }; - export interface ISql4Query { - params: Sql4Params; - result: ISql4Result; + params: Sql4Params; + result: ISql4Result; }; - - - export type Sql5Params = []; - export interface ISql5Result { - theAvg: number; + theAvg: number; }; - export interface ISql5Query { - params: Sql5Params; - result: ISql5Result; + params: Sql5Params; + result: ISql5Result; }; - - - export type Sql6Params = []; - export interface ISql6Result { - lowerVarchar: string; + lowerVarchar: string; }; - export interface ISql6Query { - params: Sql6Params; - result: ISql6Result; + params: Sql6Params; + result: ISql6Result; }; - - - export type Sql7Params = []; - export interface ISql7Result { - currentTime: string; + currentTime: string; }; - export interface ISql7Query { - params: Sql7Params; - result: ISql7Result; + params: Sql7Params; + result: ISql7Result; }; - diff --git a/tests/demo/annotations/annotations.queries.ts b/tests/demo/annotations/annotations.queries.ts index 42112d65..e69f9226 100644 --- a/tests/demo/annotations/annotations.queries.ts +++ b/tests/demo/annotations/annotations.queries.ts @@ -1,91 +1,80 @@ - - export type TestMysqlQueryParams = []; - export interface ITestMysqlQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestMysqlQueryQuery { - params: TestMysqlQueryParams; - result: ITestMysqlQueryResult; + params: TestMysqlQueryParams; + result: ITestMysqlQueryResult; }; - - - export type TestPostgresQueryParams = []; - export interface ITestPostgresQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestPostgresQueryQuery { - params: TestPostgresQueryParams; - result: ITestPostgresQueryResult; + params: TestPostgresQueryParams; + result: ITestPostgresQueryResult; }; +export type AnnotationSql3Params = []; - - -export type Sql3Params = []; - - -export interface ISql3Result { - points: string; +export interface IAnnotationSql3Result { + points: string; }; - -export interface ISql3Query { - params: Sql3Params; - result: ISql3Result; +export interface IAnnotationSql3Query { + params: AnnotationSql3Params; + result: IAnnotationSql3Result; }; +export type AnnotationSql4Params = [string]; - - -export type Sql4Params = [string]; - - -export interface ISql4Result { - food_type: string; +export interface IAnnotationSql4Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql4Query { - params: Sql4Params; - result: ISql4Result; +export interface IAnnotationSql4Query { + params: AnnotationSql4Params; + result: IAnnotationSql4Result; }; +export type AnnotationSql5Params = [string]; +export interface IAnnotationSql5Result { + tableId: boolean; +}; - -export type Sql5Params = [string]; - - -export interface ISql5Result { - tableId: boolean; +export interface IAnnotationSql5Query { + params: AnnotationSql5Params; + result: IAnnotationSql5Result; }; +export type TestMysqlQueryWithParamOverridesParams = [string]; -export interface ISql5Query { - params: Sql5Params; - result: ISql5Result; +export interface ITestMysqlQueryWithParamOverridesResult { + tableId: number; }; +export interface ITestMysqlQueryWithParamOverridesQuery { + params: TestMysqlQueryWithParamOverridesParams; + result: ITestMysqlQueryWithParamOverridesResult; +}; diff --git a/tests/demo/annotations/annotations.snapshot.ts b/tests/demo/annotations/annotations.snapshot.ts index 90e0c7f4..08f279a3 100644 --- a/tests/demo/annotations/annotations.snapshot.ts +++ b/tests/demo/annotations/annotations.snapshot.ts @@ -1,92 +1,81 @@ - - export type TestMysqlQueryParams = []; - export interface ITestMysqlQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestMysqlQueryQuery { - params: TestMysqlQueryParams; - result: ITestMysqlQueryResult; + params: TestMysqlQueryParams; + result: ITestMysqlQueryResult; }; - - - export type TestPostgresQueryParams = []; - export interface ITestPostgresQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestPostgresQueryQuery { - params: TestPostgresQueryParams; - result: ITestPostgresQueryResult; + params: TestPostgresQueryParams; + result: ITestPostgresQueryResult; }; +export type AnnotationSql3Params = []; - - -export type Sql3Params = []; - - -export interface ISql3Result { - points: string; +export interface IAnnotationSql3Result { + points: string; }; - -export interface ISql3Query { - params: Sql3Params; - result: ISql3Result; +export interface IAnnotationSql3Query { + params: AnnotationSql3Params; + result: IAnnotationSql3Result; }; +export type AnnotationSql4Params = [string]; - - -export type Sql4Params = [string]; - - -export interface ISql4Result { - food_type: string; +export interface IAnnotationSql4Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql4Query { - params: Sql4Params; - result: ISql4Result; +export interface IAnnotationSql4Query { + params: AnnotationSql4Params; + result: IAnnotationSql4Result; }; +export type AnnotationSql5Params = [string]; +export interface IAnnotationSql5Result { + tableId: boolean; +}; - -export type Sql5Params = [string]; - - -export interface ISql5Result { - tableId: boolean; +export interface IAnnotationSql5Query { + params: AnnotationSql5Params; + result: IAnnotationSql5Result; }; +export type TestMysqlQueryWithParamOverridesParams = [string]; -export interface ISql5Query { - params: Sql5Params; - result: ISql5Result; +export interface ITestMysqlQueryWithParamOverridesResult { + tableId: number; }; +export interface ITestMysqlQueryWithParamOverridesQuery { + params: TestMysqlQueryWithParamOverridesParams; + result: ITestMysqlQueryWithParamOverridesResult; +}; diff --git a/tests/demo/annotations/annotations.ts b/tests/demo/annotations/annotations.ts index 3a9dbe49..28471281 100644 --- a/tests/demo/annotations/annotations.ts +++ b/tests/demo/annotations/annotations.ts @@ -1,34 +1,34 @@ import { sql } from 'sqlx-ts' -const sql1 = sql` +const annotationSql1 = sql` -- @name: test mysql query -- @db: db_mysql SELECT * FROM items; ` -const sql2 = sql` +const annotationSql2 = sql` -- @name: test postgres query -- @db: default SELECT * FROM items; ` -const sql3 = sql` +const annotationSql3 = sql` -- @result points: string SELECT points FROM items; ` -const sql4 = sql` +const annotationSql4 = sql` -- @param 1: string SELECT * FROM items WHERE points > $1 ` -const sql5 = sql` +const annotationSql5 = sql` -- @result table_id: boolean -- @param 1: string SELECT @@ -37,3 +37,14 @@ FROM tables JOIN items ON items.table_id = tables.id WHERE tables.id = $1 ` + +const annotationSql6 = sql` +-- @name: test mysql query with param overrides +-- @db: db_mysql +-- @param 1: string +SELECT + tables.id AS table_id +FROM tables +JOIN items ON items.table_id = tables.id +WHERE tables.id = ? +` diff --git a/tests/demo/delete/delete.queries.ts b/tests/demo/delete/delete.queries.ts index 99ae8c90..4dbec772 100644 --- a/tests/demo/delete/delete.queries.ts +++ b/tests/demo/delete/delete.queries.ts @@ -1,31 +1,32 @@ +export type DeleteSql1Params = [number]; - -export type Sql1Params = [number]; - - -export interface ISql1Result { - +export interface IDeleteSql1Result { + }; - -export interface ISql1Query { - params: Sql1Params; - result: ISql1Result; +export interface IDeleteSql1Query { + params: DeleteSql1Params; + result: IDeleteSql1Result; }; +export type DeleteSql2Params = [number]; +export interface IDeleteSql2Result { + +}; - -export type Sql2Params = [number]; - - -export interface ISql2Result { - +export interface IDeleteSql2Query { + params: DeleteSql2Params; + result: IDeleteSql2Result; }; +export type DeleteSql3Params = [number, string | null]; -export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; +export interface IDeleteSql3Result { + }; +export interface IDeleteSql3Query { + params: DeleteSql3Params; + result: IDeleteSql3Result; +}; diff --git a/tests/demo/delete/delete.snapshot.ts b/tests/demo/delete/delete.snapshot.ts index 83fc9fc8..17ecbc42 100644 --- a/tests/demo/delete/delete.snapshot.ts +++ b/tests/demo/delete/delete.snapshot.ts @@ -1,32 +1,33 @@ +export type DeleteSql1Params = [number]; - -export type Sql1Params = [number]; - - -export interface ISql1Result { - +export interface IDeleteSql1Result { + }; - -export interface ISql1Query { - params: Sql1Params; - result: ISql1Result; +export interface IDeleteSql1Query { + params: DeleteSql1Params; + result: IDeleteSql1Result; }; +export type DeleteSql2Params = [number]; +export interface IDeleteSql2Result { + +}; - -export type Sql2Params = [number]; - - -export interface ISql2Result { - +export interface IDeleteSql2Query { + params: DeleteSql2Params; + result: IDeleteSql2Result; }; +export type DeleteSql3Params = [number, string | null]; -export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; +export interface IDeleteSql3Result { + }; +export interface IDeleteSql3Query { + params: DeleteSql3Params; + result: IDeleteSql3Result; +}; diff --git a/tests/demo/delete/delete.ts b/tests/demo/delete/delete.ts index 4ac36eae..1daf84a8 100644 --- a/tests/demo/delete/delete.ts +++ b/tests/demo/delete/delete.ts @@ -1,10 +1,15 @@ import { sql } from 'sqlx-ts' -const sql1 = sql` +const deleteSql1 = sql` DELETE FROM items WHERE id = $1 ` -const sql2 = sql` +const deleteSql2 = sql` DELETE FROM "items" WHERE "id" = $1 ` + +const deleteSql3 = sql` +DELETE FROM "items" +WHERE "id" = $1 AND description = $2 +` diff --git a/tests/demo/insert/returning.queries.ts b/tests/demo/insert/returning.queries.ts index 3bb2e5b7..877964fd 100644 --- a/tests/demo/insert/returning.queries.ts +++ b/tests/demo/insert/returning.queries.ts @@ -1,70 +1,63 @@ +export type InsertWildcardParams = []; - -export type WildcardParams = []; - - -export interface IWildcardResult { - foodType: string; +export interface IInsertWildcardResult { + description: string; + foodType: string; id: number; points: number; tableId: number; timeTakesToCook: number; }; - -export interface IWildcardQuery { - params: WildcardParams; - result: IWildcardResult; +export interface IInsertWildcardQuery { + params: InsertWildcardParams; + result: IInsertWildcardResult; }; +export type InsertSelectorParams = []; - - -export type SelectorParams = []; - - -export interface ISelectorResult { - foodType: string; +export interface IInsertSelectorResult { + foodType: string; id: number; }; - -export interface ISelectorQuery { - params: SelectorParams; - result: ISelectorResult; +export interface IInsertSelectorQuery { + params: InsertSelectorParams; + result: IInsertSelectorResult; }; +export type InsertAliasParams = []; - - -export type AliasParams = []; - - -export interface IAliasResult { - foodType1: string; +export interface IInsertAliasResult { + foodType1: string; id1: number; }; - -export interface IAliasQuery { - params: AliasParams; - result: IAliasResult; +export interface IInsertAliasQuery { + params: InsertAliasParams; + result: IInsertAliasResult; }; +export type InsertQuotedParams = []; +export interface IInsertQuotedResult { + foodType1: string; + id1: number; +}; +export interface IInsertQuotedQuery { + params: InsertQuotedParams; + result: IInsertQuotedResult; +}; -export type QuotedParams = []; - +export type InsertParamsParams = [string, string | null]; -export interface IQuotedResult { - foodType1: string; +export interface IInsertParamsResult { + foodType1: string; id1: number; }; - -export interface IQuotedQuery { - params: QuotedParams; - result: IQuotedResult; +export interface IInsertParamsQuery { + params: InsertParamsParams; + result: IInsertParamsResult; }; - diff --git a/tests/demo/insert/returning.snapshot.ts b/tests/demo/insert/returning.snapshot.ts index 46a48f8f..a1576c07 100644 --- a/tests/demo/insert/returning.snapshot.ts +++ b/tests/demo/insert/returning.snapshot.ts @@ -1,71 +1,64 @@ +export type InsertWildcardParams = []; - -export type WildcardParams = []; - - -export interface IWildcardResult { - foodType: string; +export interface IInsertWildcardResult { + description: string; + foodType: string; id: number; points: number; tableId: number; timeTakesToCook: number; }; - -export interface IWildcardQuery { - params: WildcardParams; - result: IWildcardResult; +export interface IInsertWildcardQuery { + params: InsertWildcardParams; + result: IInsertWildcardResult; }; +export type InsertSelectorParams = []; - - -export type SelectorParams = []; - - -export interface ISelectorResult { - foodType: string; +export interface IInsertSelectorResult { + foodType: string; id: number; }; - -export interface ISelectorQuery { - params: SelectorParams; - result: ISelectorResult; +export interface IInsertSelectorQuery { + params: InsertSelectorParams; + result: IInsertSelectorResult; }; +export type InsertAliasParams = []; - - -export type AliasParams = []; - - -export interface IAliasResult { - foodType1: string; +export interface IInsertAliasResult { + foodType1: string; id1: number; }; - -export interface IAliasQuery { - params: AliasParams; - result: IAliasResult; +export interface IInsertAliasQuery { + params: InsertAliasParams; + result: IInsertAliasResult; }; +export type InsertQuotedParams = []; +export interface IInsertQuotedResult { + foodType1: string; + id1: number; +}; +export interface IInsertQuotedQuery { + params: InsertQuotedParams; + result: IInsertQuotedResult; +}; -export type QuotedParams = []; - +export type InsertParamsParams = [string, string | null]; -export interface IQuotedResult { - foodType1: string; +export interface IInsertParamsResult { + foodType1: string; id1: number; }; - -export interface IQuotedQuery { - params: QuotedParams; - result: IQuotedResult; +export interface IInsertParamsQuery { + params: InsertParamsParams; + result: IInsertParamsResult; }; - diff --git a/tests/demo/insert/returning.ts b/tests/demo/insert/returning.ts index 80f9a2e0..9979382a 100644 --- a/tests/demo/insert/returning.ts +++ b/tests/demo/insert/returning.ts @@ -1,25 +1,32 @@ import { sql } from 'sqlx-ts' -const wildcard = sql` +const insertWildcard = sql` INSERT INTO items VALUES (1, 'korean', 20, 1, 5) RETURNING *; ` -const selector = sql` +const insertSelector = sql` INSERT INTO items VALUES (1, 'korean', 20, 1, 5) RETURNING id, food_type; ` -const alias = sql` +const insertAlias = sql` INSERT INTO items VALUES (1, 'korean', 20, 1, 5) RETURNING id as id1, food_type AS foodType1; ` -const quoted = sql` +const insertQuoted = sql` INSERT INTO "items" VALUES (1, 'korean', 20, 1, 5) RETURNING "id" as id1, food_type AS "foodType1"; ` + + +const insertParams = sql` +INSERT INTO "items" (id, food_type, time_takes_to_cook, table_id, points, description) +VALUES (1, $1, 20, 1, 5, $2) +RETURNING "id" as id1, food_type AS "foodType1"; +` diff --git a/tests/demo/select/boolean-functions.queries.ts b/tests/demo/select/boolean-functions.queries.ts index 4ed9fa4a..9e178e8e 100644 --- a/tests/demo/select/boolean-functions.queries.ts +++ b/tests/demo/select/boolean-functions.queries.ts @@ -1,63 +1,43 @@ - - export type ExistsParams = [number]; - export interface IExistsResult { - exists: boolean; + exists: boolean; }; - export interface IExistsQuery { - params: ExistsParams; - result: IExistsResult; + params: ExistsParams; + result: IExistsResult; }; - - - export type IsTrueParams = []; - export interface IIsTrueResult { - isTrue: boolean; + isTrue: boolean; }; - export interface IIsTrueQuery { - params: IsTrueParams; - result: IIsTrueResult; + params: IsTrueParams; + result: IIsTrueResult; }; - - - export type IsFalseParams = []; - export interface IIsFalseResult { - isFalse: boolean; + isFalse: boolean; }; - export interface IIsFalseQuery { - params: IsFalseParams; - result: IIsFalseResult; + params: IsFalseParams; + result: IIsFalseResult; }; - - - export type InListParams = []; - export interface IInListResult { - test: boolean; + test: boolean; }; - export interface IInListQuery { - params: InListParams; - result: IInListResult; + params: InListParams; + result: IInListResult; }; - diff --git a/tests/demo/select/boolean-functions.snapshot.ts b/tests/demo/select/boolean-functions.snapshot.ts index 1a72eeb2..3438fcc9 100644 --- a/tests/demo/select/boolean-functions.snapshot.ts +++ b/tests/demo/select/boolean-functions.snapshot.ts @@ -1,64 +1,44 @@ - - export type ExistsParams = [number]; - export interface IExistsResult { - exists: boolean; + exists: boolean; }; - export interface IExistsQuery { - params: ExistsParams; - result: IExistsResult; + params: ExistsParams; + result: IExistsResult; }; - - - export type IsTrueParams = []; - export interface IIsTrueResult { - isTrue: boolean; + isTrue: boolean; }; - export interface IIsTrueQuery { - params: IsTrueParams; - result: IIsTrueResult; + params: IsTrueParams; + result: IIsTrueResult; }; - - - export type IsFalseParams = []; - export interface IIsFalseResult { - isFalse: boolean; + isFalse: boolean; }; - export interface IIsFalseQuery { - params: IsFalseParams; - result: IIsFalseResult; + params: IsFalseParams; + result: IIsFalseResult; }; - - - export type InListParams = []; - export interface IInListResult { - test: boolean; + test: boolean; }; - export interface IInListQuery { - params: InListParams; - result: IInListResult; + params: InListParams; + result: IInListResult; }; - diff --git a/tests/demo/select/date-functions.queries.ts b/tests/demo/select/date-functions.queries.ts index 2ee1403b..918506ef 100644 --- a/tests/demo/select/date-functions.queries.ts +++ b/tests/demo/select/date-functions.queries.ts @@ -1,50 +1,35 @@ - - export type AtTimeZoneParams = []; - export interface IAtTimeZoneResult { - id: number; + id: number; someDate: Date; }; - export interface IAtTimeZoneQuery { - params: AtTimeZoneParams; - result: IAtTimeZoneResult; + params: AtTimeZoneParams; + result: IAtTimeZoneResult; }; - - - export type CastParams = []; - export interface ICastResult { - date: Date; + date: Date; id: number; }; - export interface ICastQuery { - params: CastParams; - result: ICastResult; + params: CastParams; + result: ICastResult; }; - - - export type ExtractParams = []; - export interface IExtractResult { - id: number; + id: number; theMonth: Date; }; - export interface IExtractQuery { - params: ExtractParams; - result: IExtractResult; + params: ExtractParams; + result: IExtractResult; }; - diff --git a/tests/demo/select/date-functions.snapshot.ts b/tests/demo/select/date-functions.snapshot.ts index cf56678e..50b26cb0 100644 --- a/tests/demo/select/date-functions.snapshot.ts +++ b/tests/demo/select/date-functions.snapshot.ts @@ -1,51 +1,36 @@ - - export type AtTimeZoneParams = []; - export interface IAtTimeZoneResult { - id: number; + id: number; someDate: Date; }; - export interface IAtTimeZoneQuery { - params: AtTimeZoneParams; - result: IAtTimeZoneResult; + params: AtTimeZoneParams; + result: IAtTimeZoneResult; }; - - - export type CastParams = []; - export interface ICastResult { - date: Date; + date: Date; id: number; }; - export interface ICastQuery { - params: CastParams; - result: ICastResult; + params: CastParams; + result: ICastResult; }; - - - export type ExtractParams = []; - export interface IExtractResult { - id: number; + id: number; theMonth: Date; }; - export interface IExtractQuery { - params: ExtractParams; - result: IExtractResult; + params: ExtractParams; + result: IExtractResult; }; - diff --git a/tests/demo/select/nullability.ts b/tests/demo/select/nullability.ts new file mode 100644 index 00000000..e69de29b diff --git a/tests/demo/select/number-functions.queries.ts b/tests/demo/select/number-functions.queries.ts index fc5b93c7..70067de9 100644 --- a/tests/demo/select/number-functions.queries.ts +++ b/tests/demo/select/number-functions.queries.ts @@ -1,27 +1,19 @@ - - export type CeilParams = []; - export interface ICeilResult { - id: number; + id: number; someNumber: number; }; - export interface ICeilQuery { - params: CeilParams; - result: ICeilResult; + params: CeilParams; + result: ICeilResult; }; - - - export type AllParams = []; - export interface IAllResult { - abs1: number; + abs1: number; acos1: number; asin1: number; atan1: number; @@ -55,9 +47,7 @@ export interface IAllResult { trunc1: number; }; - export interface IAllQuery { - params: AllParams; - result: IAllResult; + params: AllParams; + result: IAllResult; }; - diff --git a/tests/demo/select/number-functions.snapshot.ts b/tests/demo/select/number-functions.snapshot.ts index 689fee8c..79d83c56 100644 --- a/tests/demo/select/number-functions.snapshot.ts +++ b/tests/demo/select/number-functions.snapshot.ts @@ -1,27 +1,19 @@ - - export type CeilParams = []; - export interface ICeilResult { - id: number; + id: number; someNumber: number; }; - export interface ICeilQuery { - params: CeilParams; - result: ICeilResult; + params: CeilParams; + result: ICeilResult; }; - - - export type AllParams = []; - export interface IAllResult { - abs1: number; + abs1: number; acos1: number; asin1: number; atan1: number; @@ -55,10 +47,8 @@ export interface IAllResult { trunc1: number; }; - export interface IAllQuery { - params: AllParams; - result: IAllResult; + params: AllParams; + result: IAllResult; }; - diff --git a/tests/demo/select/select.queries.ts b/tests/demo/select/select.queries.ts index c4c650eb..8c63bda6 100644 --- a/tests/demo/select/select.queries.ts +++ b/tests/demo/select/select.queries.ts @@ -1,30 +1,24 @@ +export type SelectSql1Params = []; - -export type Sql1Params = []; - - -export interface ISql1Result { - food_type: string; +export interface ISelectSql1Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql1Query { - params: Sql1Params; - result: ISql1Result; +export interface ISelectSql1Query { + params: SelectSql1Params; + result: ISelectSql1Result; }; +export type SelectSql2Params = []; - - -export type Sql2Params = []; - - -export interface ISql2Result { - food_type: string; +export interface ISelectSql2Result { + description: string | null; + food_type: string; id: number; number: number; occupied: boolean; @@ -33,56 +27,43 @@ export interface ISql2Result { time_takes_to_cook: number; }; - -export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; +export interface ISelectSql2Query { + params: SelectSql2Params; + result: ISelectSql2Result; }; +export type SelectSql3Params = []; - - -export type Sql3Params = []; - - -export interface ISql3Result { - tableNumber: number; +export interface ISelectSql3Result { + tableNumber: number; }; - -export interface ISql3Query { - params: Sql3Params; - result: ISql3Result; +export interface ISelectSql3Query { + params: SelectSql3Params; + result: ISelectSql3Result; }; +export type SelectSql4Params = []; - - -export type Sql4Params = []; - - -export interface ISql4Result { - food_type: string; +export interface ISelectSql4Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql4Query { - params: Sql4Params; - result: ISql4Result; +export interface ISelectSql4Query { + params: SelectSql4Params; + result: ISelectSql4Result; }; +export type SelectSql5Params = []; - - -export type Sql5Params = []; - - -export interface ISql5Result { - food_type: string; +export interface ISelectSql5Result { + description: string | null; + food_type: string; id: number; number: number; occupied: boolean; @@ -91,154 +72,115 @@ export interface ISql5Result { time_takes_to_cook: number; }; - -export interface ISql5Query { - params: Sql5Params; - result: ISql5Result; +export interface ISelectSql5Query { + params: SelectSql5Params; + result: ISelectSql5Result; }; +export type SelectSql6Params = [number, number]; - - -export type Sql6Params = [number, number]; - - -export interface ISql6Result { - id: number; +export interface ISelectSql6Result { + id: number; }; - -export interface ISql6Query { - params: Sql6Params; - result: ISql6Result; +export interface ISelectSql6Query { + params: SelectSql6Params; + result: ISelectSql6Result; }; +export type SelectSql9Params = [boolean]; - - -export type Sql9Params = [boolean]; - - -export interface ISql9Result { - food_type: string; +export interface ISelectSql9Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql9Query { - params: Sql9Params; - result: ISql9Result; +export interface ISelectSql9Query { + params: SelectSql9Params; + result: ISelectSql9Result; }; +export type SelectSql10Params = []; - - -export type Sql10Params = []; - - -export interface ISql10Result { - id: number; +export interface ISelectSql10Result { + id: number; number: number; occupied: boolean; }; - -export interface ISql10Query { - params: Sql10Params; - result: ISql10Result; +export interface ISelectSql10Query { + params: SelectSql10Params; + result: ISelectSql10Result; }; +export type SelectSql11Params = [string, string]; - - -export type Sql11Params = [string, string]; - - -export interface ISql11Result { - hmm: any; +export interface ISelectSql11Result { + hmm: any; id: number; number: number; }; - -export interface ISql11Query { - params: Sql11Params; - result: ISql11Result; +export interface ISelectSql11Query { + params: SelectSql11Params; + result: ISelectSql11Result; }; +export type SelectSql12Params = [number]; - - -export type Sql12Params = [number]; - - -export interface ISql12Result { - id: number; +export interface ISelectSql12Result { + id: number; }; - -export interface ISql12Query { - params: Sql12Params; - result: ISql12Result; +export interface ISelectSql12Query { + params: SelectSql12Params; + result: ISelectSql12Result; }; +export type SelectSql13Params = [string]; - - -export type Sql13Params = [string]; - - -export interface ISql13Result { - food_type: string; +export interface ISelectSql13Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql13Query { - params: Sql13Params; - result: ISql13Result; +export interface ISelectSql13Query { + params: SelectSql13Params; + result: ISelectSql13Result; }; +export type SelectSql14Params = [number]; - - -export type Sql14Params = [number]; - - -export interface ISql14Result { - food_type: string; +export interface ISelectSql14Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql14Query { - params: Sql14Params; - result: ISql14Result; +export interface ISelectSql14Query { + params: SelectSql14Params; + result: ISelectSql14Result; }; +export type SelectSql15Params = []; - - -export type Sql15Params = []; - - -export interface ISql15Result { - id2: number; +export interface ISelectSql15Result { + id2: number; itemsId: number; }; - -export interface ISql15Query { - params: Sql15Params; - result: ISql15Result; +export interface ISelectSql15Query { + params: SelectSql15Params; + result: ISelectSql15Result; }; - diff --git a/tests/demo/select/select.snapshot.ts b/tests/demo/select/select.snapshot.ts index 7f1a74d0..e143f9fd 100644 --- a/tests/demo/select/select.snapshot.ts +++ b/tests/demo/select/select.snapshot.ts @@ -1,30 +1,24 @@ +export type SelectSql1Params = []; - -export type Sql1Params = []; - - -export interface ISql1Result { - food_type: string; +export interface ISelectSql1Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql1Query { - params: Sql1Params; - result: ISql1Result; +export interface ISelectSql1Query { + params: SelectSql1Params; + result: ISelectSql1Result; }; +export type SelectSql2Params = []; - - -export type Sql2Params = []; - - -export interface ISql2Result { - food_type: string; +export interface ISelectSql2Result { + description: string | null; + food_type: string; id: number; number: number; occupied: boolean; @@ -33,56 +27,43 @@ export interface ISql2Result { time_takes_to_cook: number; }; - -export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; +export interface ISelectSql2Query { + params: SelectSql2Params; + result: ISelectSql2Result; }; +export type SelectSql3Params = []; - - -export type Sql3Params = []; - - -export interface ISql3Result { - tableNumber: number; +export interface ISelectSql3Result { + tableNumber: number; }; - -export interface ISql3Query { - params: Sql3Params; - result: ISql3Result; +export interface ISelectSql3Query { + params: SelectSql3Params; + result: ISelectSql3Result; }; +export type SelectSql4Params = []; - - -export type Sql4Params = []; - - -export interface ISql4Result { - food_type: string; +export interface ISelectSql4Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql4Query { - params: Sql4Params; - result: ISql4Result; +export interface ISelectSql4Query { + params: SelectSql4Params; + result: ISelectSql4Result; }; +export type SelectSql5Params = []; - - -export type Sql5Params = []; - - -export interface ISql5Result { - food_type: string; +export interface ISelectSql5Result { + description: string | null; + food_type: string; id: number; number: number; occupied: boolean; @@ -91,155 +72,116 @@ export interface ISql5Result { time_takes_to_cook: number; }; - -export interface ISql5Query { - params: Sql5Params; - result: ISql5Result; +export interface ISelectSql5Query { + params: SelectSql5Params; + result: ISelectSql5Result; }; +export type SelectSql6Params = [number, number]; - - -export type Sql6Params = [number, number]; - - -export interface ISql6Result { - id: number; +export interface ISelectSql6Result { + id: number; }; - -export interface ISql6Query { - params: Sql6Params; - result: ISql6Result; +export interface ISelectSql6Query { + params: SelectSql6Params; + result: ISelectSql6Result; }; +export type SelectSql9Params = [boolean]; - - -export type Sql9Params = [boolean]; - - -export interface ISql9Result { - food_type: string; +export interface ISelectSql9Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql9Query { - params: Sql9Params; - result: ISql9Result; +export interface ISelectSql9Query { + params: SelectSql9Params; + result: ISelectSql9Result; }; +export type SelectSql10Params = []; - - -export type Sql10Params = []; - - -export interface ISql10Result { - id: number; +export interface ISelectSql10Result { + id: number; number: number; occupied: boolean; }; - -export interface ISql10Query { - params: Sql10Params; - result: ISql10Result; +export interface ISelectSql10Query { + params: SelectSql10Params; + result: ISelectSql10Result; }; +export type SelectSql11Params = [string, string]; - - -export type Sql11Params = [string, string]; - - -export interface ISql11Result { - hmm: any; +export interface ISelectSql11Result { + hmm: any; id: number; number: number; }; - -export interface ISql11Query { - params: Sql11Params; - result: ISql11Result; +export interface ISelectSql11Query { + params: SelectSql11Params; + result: ISelectSql11Result; }; +export type SelectSql12Params = [number]; - - -export type Sql12Params = [number]; - - -export interface ISql12Result { - id: number; +export interface ISelectSql12Result { + id: number; }; - -export interface ISql12Query { - params: Sql12Params; - result: ISql12Result; +export interface ISelectSql12Query { + params: SelectSql12Params; + result: ISelectSql12Result; }; +export type SelectSql13Params = [string]; - - -export type Sql13Params = [string]; - - -export interface ISql13Result { - food_type: string; +export interface ISelectSql13Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql13Query { - params: Sql13Params; - result: ISql13Result; +export interface ISelectSql13Query { + params: SelectSql13Params; + result: ISelectSql13Result; }; +export type SelectSql14Params = [number]; - - -export type Sql14Params = [number]; - - -export interface ISql14Result { - food_type: string; +export interface ISelectSql14Result { + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - -export interface ISql14Query { - params: Sql14Params; - result: ISql14Result; +export interface ISelectSql14Query { + params: SelectSql14Params; + result: ISelectSql14Result; }; +export type SelectSql15Params = []; - - -export type Sql15Params = []; - - -export interface ISql15Result { - id2: number; +export interface ISelectSql15Result { + id2: number; itemsId: number; }; - -export interface ISql15Query { - params: Sql15Params; - result: ISql15Result; +export interface ISelectSql15Query { + params: SelectSql15Params; + result: ISelectSql15Result; }; - diff --git a/tests/demo/select/select.ts b/tests/demo/select/select.ts index 101a217a..e51b0e4b 100644 --- a/tests/demo/select/select.ts +++ b/tests/demo/select/select.ts @@ -1,80 +1,80 @@ import { sql } from 'sqlx-ts' // simple select -const sql1 = sql`SELECT * FROM items` +const selectSql1 = sql`SELECT * FROM items` // single join -const sql2 = sql` +const selectSql2 = sql` SELECT * FROM items JOIN tables ON items.table_id = tables.id ` // subquery -const sql3 = sql` +const selectSql3 = sql` SELECT (SELECT number FROM tables WHERE tables.id = items.table_id) AS table_number FROM items ` // wildcard -const sql4 = sql` +const selectSql4 = sql` SELECT items.* FROM items; ` // table wit joins -const sql5 = sql` +const selectSql5 = sql` SELECT tables.* FROM items JOIN tables ON items.table_id = tables.id ` // Various operators -const sql6 = sql` +const selectSql6 = sql` SELECT id FROM items WHERE points BETWEEN $1 AND $2; ` // Where condition expressions -const sql9 = sql` +const selectSql9 = sql` SELECT * FROM items WHERE $1; ` -const sql10 = sql` +const selectSql10 = sql` SELECT * FROM tables WHERE occupied IS TRUE; ` // IS DISTINCT FROM operator as part of the WHERE statement -const sql11 = sql` +const selectSql11 = sql` SELECT id, number, id IS DISTINCT FROM $1 AS hmm FROM tables WHERE id IS DISTINCT FROM $2 ` -const sql12 = sql` +const selectSql12 = sql` SELECT id FROM tables WHERE tables.id = $1 ` -const sql13 = sql` +const selectSql13 = sql` SELECT * FROM items WHERE food_type LIKE $1 ` // SELECT with quoted table names -const sql14 = sql` +const selectSql14 = sql` SELECT * FROM "items" WHERE id = $1 ` -const sql15 = sql` +const selectSql15 = sql` SELECT "items"."id", "tables"."id" AS "id2", items.id FROM "items" JOIN "tables" ON "items"."table_id" = "tables"."id" diff --git a/tests/demo/typescript/decorators.queries.ts b/tests/demo/typescript/decorators.queries.ts index 571e4662..437a8895 100644 --- a/tests/demo/typescript/decorators.queries.ts +++ b/tests/demo/typescript/decorators.queries.ts @@ -1,239 +1,164 @@ - - export type PrivDecoConstructorParams = []; - export interface IPrivDecoConstructorResult { - id: number; + id: number; }; - export interface IPrivDecoConstructorQuery { - params: PrivDecoConstructorParams; - result: IPrivDecoConstructorResult; + params: PrivDecoConstructorParams; + result: IPrivDecoConstructorResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PubDecoMethodParams = []; - export interface IPubDecoMethodResult { - id: number; + id: number; }; - export interface IPubDecoMethodQuery { - params: PubDecoMethodParams; - result: IPubDecoMethodResult; + params: PubDecoMethodParams; + result: IPubDecoMethodResult; }; - - - export type ProtDecoMethodParams = []; - export interface IProtDecoMethodResult { - id: number; + id: number; }; - export interface IProtDecoMethodQuery { - params: ProtDecoMethodParams; - result: IProtDecoMethodResult; + params: ProtDecoMethodParams; + result: IProtDecoMethodResult; }; - - - export type PrivDecoConstructorParams = []; - export interface IPrivDecoConstructorResult { - id: number; + id: number; }; - export interface IPrivDecoConstructorQuery { - params: PrivDecoConstructorParams; - result: IPrivDecoConstructorResult; + params: PrivDecoConstructorParams; + result: IPrivDecoConstructorResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PubDecoMethodParams = []; - export interface IPubDecoMethodResult { - id: number; + id: number; }; - export interface IPubDecoMethodQuery { - params: PubDecoMethodParams; - result: IPubDecoMethodResult; + params: PubDecoMethodParams; + result: IPubDecoMethodResult; }; - - - export type ProtDecoMethodParams = []; - export interface IProtDecoMethodResult { - id: number; + id: number; }; - export interface IProtDecoMethodQuery { - params: ProtDecoMethodParams; - result: IProtDecoMethodResult; + params: ProtDecoMethodParams; + result: IProtDecoMethodResult; }; - - - export type PrivDecoConstructorParams = []; - export interface IPrivDecoConstructorResult { - id: number; + id: number; }; - export interface IPrivDecoConstructorQuery { - params: PrivDecoConstructorParams; - result: IPrivDecoConstructorResult; + params: PrivDecoConstructorParams; + result: IPrivDecoConstructorResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PubDecoMethodParams = []; - export interface IPubDecoMethodResult { - id: number; + id: number; }; - export interface IPubDecoMethodQuery { - params: PubDecoMethodParams; - result: IPubDecoMethodResult; + params: PubDecoMethodParams; + result: IPubDecoMethodResult; }; - - - export type ProtDecoMethodParams = []; - export interface IProtDecoMethodResult { - id: number; + id: number; }; - export interface IProtDecoMethodQuery { - params: ProtDecoMethodParams; - result: IProtDecoMethodResult; + params: ProtDecoMethodParams; + result: IProtDecoMethodResult; }; - diff --git a/tests/demo/typescript/decorators.snapshot.ts b/tests/demo/typescript/decorators.snapshot.ts index 959b863d..2f0d9b73 100644 --- a/tests/demo/typescript/decorators.snapshot.ts +++ b/tests/demo/typescript/decorators.snapshot.ts @@ -1,240 +1,165 @@ - - export type PrivDecoConstructorParams = []; - export interface IPrivDecoConstructorResult { - id: number; + id: number; }; - export interface IPrivDecoConstructorQuery { - params: PrivDecoConstructorParams; - result: IPrivDecoConstructorResult; + params: PrivDecoConstructorParams; + result: IPrivDecoConstructorResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PubDecoMethodParams = []; - export interface IPubDecoMethodResult { - id: number; + id: number; }; - export interface IPubDecoMethodQuery { - params: PubDecoMethodParams; - result: IPubDecoMethodResult; + params: PubDecoMethodParams; + result: IPubDecoMethodResult; }; - - - export type ProtDecoMethodParams = []; - export interface IProtDecoMethodResult { - id: number; + id: number; }; - export interface IProtDecoMethodQuery { - params: ProtDecoMethodParams; - result: IProtDecoMethodResult; + params: ProtDecoMethodParams; + result: IProtDecoMethodResult; }; - - - export type PrivDecoConstructorParams = []; - export interface IPrivDecoConstructorResult { - id: number; + id: number; }; - export interface IPrivDecoConstructorQuery { - params: PrivDecoConstructorParams; - result: IPrivDecoConstructorResult; + params: PrivDecoConstructorParams; + result: IPrivDecoConstructorResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PubDecoMethodParams = []; - export interface IPubDecoMethodResult { - id: number; + id: number; }; - export interface IPubDecoMethodQuery { - params: PubDecoMethodParams; - result: IPubDecoMethodResult; + params: PubDecoMethodParams; + result: IPubDecoMethodResult; }; - - - export type ProtDecoMethodParams = []; - export interface IProtDecoMethodResult { - id: number; + id: number; }; - export interface IProtDecoMethodQuery { - params: ProtDecoMethodParams; - result: IProtDecoMethodResult; + params: ProtDecoMethodParams; + result: IProtDecoMethodResult; }; - - - export type PrivDecoConstructorParams = []; - export interface IPrivDecoConstructorResult { - id: number; + id: number; }; - export interface IPrivDecoConstructorQuery { - params: PrivDecoConstructorParams; - result: IPrivDecoConstructorResult; + params: PrivDecoConstructorParams; + result: IPrivDecoConstructorResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PrivDecoMethodParams = []; - export interface IPrivDecoMethodResult { - id: number; + id: number; }; - export interface IPrivDecoMethodQuery { - params: PrivDecoMethodParams; - result: IPrivDecoMethodResult; + params: PrivDecoMethodParams; + result: IPrivDecoMethodResult; }; - - - export type PubDecoMethodParams = []; - export interface IPubDecoMethodResult { - id: number; + id: number; }; - export interface IPubDecoMethodQuery { - params: PubDecoMethodParams; - result: IPubDecoMethodResult; + params: PubDecoMethodParams; + result: IPubDecoMethodResult; }; - - - export type ProtDecoMethodParams = []; - export interface IProtDecoMethodResult { - id: number; + id: number; }; - export interface IProtDecoMethodQuery { - params: ProtDecoMethodParams; - result: IProtDecoMethodResult; + params: ProtDecoMethodParams; + result: IProtDecoMethodResult; }; - diff --git a/tests/demo/typescript/demo.queries.ts b/tests/demo/typescript/demo.queries.ts index 56dfa16f..6422bb71 100644 --- a/tests/demo/typescript/demo.queries.ts +++ b/tests/demo/typescript/demo.queries.ts @@ -1,115 +1,90 @@ - - export type TestSequelizeQueryParams = [number]; - export interface ITestSequelizeQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestSequelizeQueryQuery { - params: TestSequelizeQueryParams; - result: ITestSequelizeQueryResult; + params: TestSequelizeQueryParams; + result: ITestSequelizeQueryResult; }; - - - export type TestAwaitQueryParams = []; - export interface ITestAwaitQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestAwaitQueryQuery { - params: TestAwaitQueryParams; - result: ITestAwaitQueryResult; + params: TestAwaitQueryParams; + result: ITestAwaitQueryResult; }; - - - export type TestAwaitQuery2Params = []; - export interface ITestAwaitQuery2Result { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestAwaitQuery2Query { - params: TestAwaitQuery2Params; - result: ITestAwaitQuery2Result; + params: TestAwaitQuery2Params; + result: ITestAwaitQuery2Result; }; - - - export type AwaitClientQueryParams = []; - export interface IAwaitClientQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IAwaitClientQueryQuery { - params: AwaitClientQueryParams; - result: IAwaitClientQueryResult; + params: AwaitClientQueryParams; + result: IAwaitClientQueryResult; }; - - - export type GetItemsWithRowsParams = []; - export interface IGetItemsWithRowsResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IGetItemsWithRowsQuery { - params: GetItemsWithRowsParams; - result: IGetItemsWithRowsResult; + params: GetItemsWithRowsParams; + result: IGetItemsWithRowsResult; }; - - - export type TestInsertParams = [[string, number]]; - export interface ITestInsertResult { - + }; - export interface ITestInsertQuery { - params: TestInsertParams; - result: ITestInsertResult; + params: TestInsertParams; + result: ITestInsertResult; }; - diff --git a/tests/demo/typescript/demo.snapshot.ts b/tests/demo/typescript/demo.snapshot.ts index 108cff7f..8a38b6d3 100644 --- a/tests/demo/typescript/demo.snapshot.ts +++ b/tests/demo/typescript/demo.snapshot.ts @@ -1,116 +1,91 @@ - - export type TestSequelizeQueryParams = [number]; - export interface ITestSequelizeQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestSequelizeQueryQuery { - params: TestSequelizeQueryParams; - result: ITestSequelizeQueryResult; + params: TestSequelizeQueryParams; + result: ITestSequelizeQueryResult; }; - - - export type TestAwaitQueryParams = []; - export interface ITestAwaitQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestAwaitQueryQuery { - params: TestAwaitQueryParams; - result: ITestAwaitQueryResult; + params: TestAwaitQueryParams; + result: ITestAwaitQueryResult; }; - - - export type TestAwaitQuery2Params = []; - export interface ITestAwaitQuery2Result { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestAwaitQuery2Query { - params: TestAwaitQuery2Params; - result: ITestAwaitQuery2Result; + params: TestAwaitQuery2Params; + result: ITestAwaitQuery2Result; }; - - - export type AwaitClientQueryParams = []; - export interface IAwaitClientQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IAwaitClientQueryQuery { - params: AwaitClientQueryParams; - result: IAwaitClientQueryResult; + params: AwaitClientQueryParams; + result: IAwaitClientQueryResult; }; - - - export type GetItemsWithRowsParams = []; - export interface IGetItemsWithRowsResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IGetItemsWithRowsQuery { - params: GetItemsWithRowsParams; - result: IGetItemsWithRowsResult; + params: GetItemsWithRowsParams; + result: IGetItemsWithRowsResult; }; - - - export type TestInsertParams = [[string, number]]; - export interface ITestInsertResult { - + }; - export interface ITestInsertQuery { - params: TestInsertParams; - result: ITestInsertResult; + params: TestInsertParams; + result: ITestInsertResult; }; - diff --git a/tests/demo/typescript/expression/array.queries.ts b/tests/demo/typescript/expression/array.queries.ts index 954aa14c..9be4f2ce 100644 --- a/tests/demo/typescript/expression/array.queries.ts +++ b/tests/demo/typescript/expression/array.queries.ts @@ -1,15 +1,10 @@ - - export type ArrayQueryParams = []; - export interface IArrayQueryResult { - id: number; + id: number; }; - export interface IArrayQueryQuery { - params: ArrayQueryParams; - result: IArrayQueryResult; + params: ArrayQueryParams; + result: IArrayQueryResult; }; - diff --git a/tests/demo/typescript/expression/array.snapshot.ts b/tests/demo/typescript/expression/array.snapshot.ts index 647b9ea3..edadd5b0 100644 --- a/tests/demo/typescript/expression/array.snapshot.ts +++ b/tests/demo/typescript/expression/array.snapshot.ts @@ -1,16 +1,11 @@ - - export type ArrayQueryParams = []; - export interface IArrayQueryResult { - id: number; + id: number; }; - export interface IArrayQueryQuery { - params: ArrayQueryParams; - result: IArrayQueryResult; + params: ArrayQueryParams; + result: IArrayQueryResult; }; - diff --git a/tests/demo/typescript/expression/arrow-function.queries.ts b/tests/demo/typescript/expression/arrow-function.queries.ts index fd5cea99..8564146e 100644 --- a/tests/demo/typescript/expression/arrow-function.queries.ts +++ b/tests/demo/typescript/expression/arrow-function.queries.ts @@ -1,47 +1,32 @@ - - export type PlainArrowFunctionParams = []; - export interface IPlainArrowFunctionResult { - id: number; + id: number; }; - export interface IPlainArrowFunctionQuery { - params: PlainArrowFunctionParams; - result: IPlainArrowFunctionResult; + params: PlainArrowFunctionParams; + result: IPlainArrowFunctionResult; }; - - - export type NameOverriddenArrowFuncParams = []; - export interface INameOverriddenArrowFuncResult { - id: number; + id: number; }; - export interface INameOverriddenArrowFuncQuery { - params: NameOverriddenArrowFuncParams; - result: INameOverriddenArrowFuncResult; + params: NameOverriddenArrowFuncParams; + result: INameOverriddenArrowFuncResult; }; - - - export type ArrowFunctionParams = []; - export interface IArrowFunctionResult { - id: number; + id: number; }; - export interface IArrowFunctionQuery { - params: ArrowFunctionParams; - result: IArrowFunctionResult; + params: ArrowFunctionParams; + result: IArrowFunctionResult; }; - diff --git a/tests/demo/typescript/expression/arrow-function.snapshot.ts b/tests/demo/typescript/expression/arrow-function.snapshot.ts index 7a6efe50..5df87136 100644 --- a/tests/demo/typescript/expression/arrow-function.snapshot.ts +++ b/tests/demo/typescript/expression/arrow-function.snapshot.ts @@ -1,48 +1,33 @@ - - export type PlainArrowFunctionParams = []; - export interface IPlainArrowFunctionResult { - id: number; + id: number; }; - export interface IPlainArrowFunctionQuery { - params: PlainArrowFunctionParams; - result: IPlainArrowFunctionResult; + params: PlainArrowFunctionParams; + result: IPlainArrowFunctionResult; }; - - - export type NameOverriddenArrowFuncParams = []; - export interface INameOverriddenArrowFuncResult { - id: number; + id: number; }; - export interface INameOverriddenArrowFuncQuery { - params: NameOverriddenArrowFuncParams; - result: INameOverriddenArrowFuncResult; + params: NameOverriddenArrowFuncParams; + result: INameOverriddenArrowFuncResult; }; - - - export type ArrowFunctionParams = []; - export interface IArrowFunctionResult { - id: number; + id: number; }; - export interface IArrowFunctionQuery { - params: ArrowFunctionParams; - result: IArrowFunctionResult; + params: ArrowFunctionParams; + result: IArrowFunctionResult; }; - diff --git a/tests/demo/typescript/expression/assignment.queries.ts b/tests/demo/typescript/expression/assignment.queries.ts index 65c1bdba..7bcbc041 100644 --- a/tests/demo/typescript/expression/assignment.queries.ts +++ b/tests/demo/typescript/expression/assignment.queries.ts @@ -1,255 +1,175 @@ - - export type AssignmentParams = []; - export interface IAssignmentResult { - id: number; + id: number; }; - export interface IAssignmentQuery { - params: AssignmentParams; - result: IAssignmentResult; + params: AssignmentParams; + result: IAssignmentResult; }; - - - export type PlusEqualQueryParams = []; - export interface IPlusEqualQueryResult { - id: number; + id: number; }; - export interface IPlusEqualQueryQuery { - params: PlusEqualQueryParams; - result: IPlusEqualQueryResult; + params: PlusEqualQueryParams; + result: IPlusEqualQueryResult; }; - - - export type MinusEqualQueryParams = []; - export interface IMinusEqualQueryResult { - id: number; + id: number; }; - export interface IMinusEqualQueryQuery { - params: MinusEqualQueryParams; - result: IMinusEqualQueryResult; + params: MinusEqualQueryParams; + result: IMinusEqualQueryResult; }; - - - export type MultiplyEqualQueryParams = []; - export interface IMultiplyEqualQueryResult { - id: number; + id: number; }; - export interface IMultiplyEqualQueryQuery { - params: MultiplyEqualQueryParams; - result: IMultiplyEqualQueryResult; + params: MultiplyEqualQueryParams; + result: IMultiplyEqualQueryResult; }; - - - export type MulMulEqualQueryParams = []; - export interface IMulMulEqualQueryResult { - id: number; + id: number; }; - export interface IMulMulEqualQueryQuery { - params: MulMulEqualQueryParams; - result: IMulMulEqualQueryResult; + params: MulMulEqualQueryParams; + result: IMulMulEqualQueryResult; }; - - - export type SlashEqualQueryParams = []; - export interface ISlashEqualQueryResult { - id: number; + id: number; }; - export interface ISlashEqualQueryQuery { - params: SlashEqualQueryParams; - result: ISlashEqualQueryResult; + params: SlashEqualQueryParams; + result: ISlashEqualQueryResult; }; - - - export type PercentEqualQueryParams = []; - export interface IPercentEqualQueryResult { - id: number; + id: number; }; - export interface IPercentEqualQueryQuery { - params: PercentEqualQueryParams; - result: IPercentEqualQueryResult; + params: PercentEqualQueryParams; + result: IPercentEqualQueryResult; }; - - - export type LessLessEqualQueryParams = []; - export interface ILessLessEqualQueryResult { - id: number; + id: number; }; - export interface ILessLessEqualQueryQuery { - params: LessLessEqualQueryParams; - result: ILessLessEqualQueryResult; + params: LessLessEqualQueryParams; + result: ILessLessEqualQueryResult; }; - - - export type GreaterGreaterEqualQueryParams = []; - export interface IGreaterGreaterEqualQueryResult { - id: number; + id: number; }; - export interface IGreaterGreaterEqualQueryQuery { - params: GreaterGreaterEqualQueryParams; - result: IGreaterGreaterEqualQueryResult; + params: GreaterGreaterEqualQueryParams; + result: IGreaterGreaterEqualQueryResult; }; - - - export type GreaterGreaterGreaterEqualQueryParams = []; - export interface IGreaterGreaterGreaterEqualQueryResult { - id: number; + id: number; }; - export interface IGreaterGreaterGreaterEqualQueryQuery { - params: GreaterGreaterGreaterEqualQueryParams; - result: IGreaterGreaterGreaterEqualQueryResult; + params: GreaterGreaterGreaterEqualQueryParams; + result: IGreaterGreaterGreaterEqualQueryResult; }; - - - export type AmpersandEqualQueryParams = []; - export interface IAmpersandEqualQueryResult { - id: number; + id: number; }; - export interface IAmpersandEqualQueryQuery { - params: AmpersandEqualQueryParams; - result: IAmpersandEqualQueryResult; + params: AmpersandEqualQueryParams; + result: IAmpersandEqualQueryResult; }; - - - export type AmpersandAmpersandEqualQueryParams = []; - export interface IAmpersandAmpersandEqualQueryResult { - id: number; + id: number; }; - export interface IAmpersandAmpersandEqualQueryQuery { - params: AmpersandAmpersandEqualQueryParams; - result: IAmpersandAmpersandEqualQueryResult; + params: AmpersandAmpersandEqualQueryParams; + result: IAmpersandAmpersandEqualQueryResult; }; - - - export type BarEqualQueryParams = []; - export interface IBarEqualQueryResult { - id: number; + id: number; }; - export interface IBarEqualQueryQuery { - params: BarEqualQueryParams; - result: IBarEqualQueryResult; + params: BarEqualQueryParams; + result: IBarEqualQueryResult; }; - - - export type BarBarEqualQueryParams = []; - export interface IBarBarEqualQueryResult { - id: number; + id: number; }; - export interface IBarBarEqualQueryQuery { - params: BarBarEqualQueryParams; - result: IBarBarEqualQueryResult; + params: BarBarEqualQueryParams; + result: IBarBarEqualQueryResult; }; - - - export type QuestionQuestionEqualQueryParams = []; - export interface IQuestionQuestionEqualQueryResult { - id: number; + id: number; }; - export interface IQuestionQuestionEqualQueryQuery { - params: QuestionQuestionEqualQueryParams; - result: IQuestionQuestionEqualQueryResult; + params: QuestionQuestionEqualQueryParams; + result: IQuestionQuestionEqualQueryResult; }; - - - export type CaretEqualQueryParams = []; - export interface ICaretEqualQueryResult { - id: number; + id: number; }; - export interface ICaretEqualQueryQuery { - params: CaretEqualQueryParams; - result: ICaretEqualQueryResult; + params: CaretEqualQueryParams; + result: ICaretEqualQueryResult; }; - diff --git a/tests/demo/typescript/expression/assignment.snapshot.ts b/tests/demo/typescript/expression/assignment.snapshot.ts index bbc5deb1..d60af75b 100644 --- a/tests/demo/typescript/expression/assignment.snapshot.ts +++ b/tests/demo/typescript/expression/assignment.snapshot.ts @@ -1,256 +1,176 @@ - - export type AssignmentParams = []; - export interface IAssignmentResult { - id: number; + id: number; }; - export interface IAssignmentQuery { - params: AssignmentParams; - result: IAssignmentResult; + params: AssignmentParams; + result: IAssignmentResult; }; - - - export type PlusEqualQueryParams = []; - export interface IPlusEqualQueryResult { - id: number; + id: number; }; - export interface IPlusEqualQueryQuery { - params: PlusEqualQueryParams; - result: IPlusEqualQueryResult; + params: PlusEqualQueryParams; + result: IPlusEqualQueryResult; }; - - - export type MinusEqualQueryParams = []; - export interface IMinusEqualQueryResult { - id: number; + id: number; }; - export interface IMinusEqualQueryQuery { - params: MinusEqualQueryParams; - result: IMinusEqualQueryResult; + params: MinusEqualQueryParams; + result: IMinusEqualQueryResult; }; - - - export type MultiplyEqualQueryParams = []; - export interface IMultiplyEqualQueryResult { - id: number; + id: number; }; - export interface IMultiplyEqualQueryQuery { - params: MultiplyEqualQueryParams; - result: IMultiplyEqualQueryResult; + params: MultiplyEqualQueryParams; + result: IMultiplyEqualQueryResult; }; - - - export type MulMulEqualQueryParams = []; - export interface IMulMulEqualQueryResult { - id: number; + id: number; }; - export interface IMulMulEqualQueryQuery { - params: MulMulEqualQueryParams; - result: IMulMulEqualQueryResult; + params: MulMulEqualQueryParams; + result: IMulMulEqualQueryResult; }; - - - export type SlashEqualQueryParams = []; - export interface ISlashEqualQueryResult { - id: number; + id: number; }; - export interface ISlashEqualQueryQuery { - params: SlashEqualQueryParams; - result: ISlashEqualQueryResult; + params: SlashEqualQueryParams; + result: ISlashEqualQueryResult; }; - - - export type PercentEqualQueryParams = []; - export interface IPercentEqualQueryResult { - id: number; + id: number; }; - export interface IPercentEqualQueryQuery { - params: PercentEqualQueryParams; - result: IPercentEqualQueryResult; + params: PercentEqualQueryParams; + result: IPercentEqualQueryResult; }; - - - export type LessLessEqualQueryParams = []; - export interface ILessLessEqualQueryResult { - id: number; + id: number; }; - export interface ILessLessEqualQueryQuery { - params: LessLessEqualQueryParams; - result: ILessLessEqualQueryResult; + params: LessLessEqualQueryParams; + result: ILessLessEqualQueryResult; }; - - - export type GreaterGreaterEqualQueryParams = []; - export interface IGreaterGreaterEqualQueryResult { - id: number; + id: number; }; - export interface IGreaterGreaterEqualQueryQuery { - params: GreaterGreaterEqualQueryParams; - result: IGreaterGreaterEqualQueryResult; + params: GreaterGreaterEqualQueryParams; + result: IGreaterGreaterEqualQueryResult; }; - - - export type GreaterGreaterGreaterEqualQueryParams = []; - export interface IGreaterGreaterGreaterEqualQueryResult { - id: number; + id: number; }; - export interface IGreaterGreaterGreaterEqualQueryQuery { - params: GreaterGreaterGreaterEqualQueryParams; - result: IGreaterGreaterGreaterEqualQueryResult; + params: GreaterGreaterGreaterEqualQueryParams; + result: IGreaterGreaterGreaterEqualQueryResult; }; - - - export type AmpersandEqualQueryParams = []; - export interface IAmpersandEqualQueryResult { - id: number; + id: number; }; - export interface IAmpersandEqualQueryQuery { - params: AmpersandEqualQueryParams; - result: IAmpersandEqualQueryResult; + params: AmpersandEqualQueryParams; + result: IAmpersandEqualQueryResult; }; - - - export type AmpersandAmpersandEqualQueryParams = []; - export interface IAmpersandAmpersandEqualQueryResult { - id: number; + id: number; }; - export interface IAmpersandAmpersandEqualQueryQuery { - params: AmpersandAmpersandEqualQueryParams; - result: IAmpersandAmpersandEqualQueryResult; + params: AmpersandAmpersandEqualQueryParams; + result: IAmpersandAmpersandEqualQueryResult; }; - - - export type BarEqualQueryParams = []; - export interface IBarEqualQueryResult { - id: number; + id: number; }; - export interface IBarEqualQueryQuery { - params: BarEqualQueryParams; - result: IBarEqualQueryResult; + params: BarEqualQueryParams; + result: IBarEqualQueryResult; }; - - - export type BarBarEqualQueryParams = []; - export interface IBarBarEqualQueryResult { - id: number; + id: number; }; - export interface IBarBarEqualQueryQuery { - params: BarBarEqualQueryParams; - result: IBarBarEqualQueryResult; + params: BarBarEqualQueryParams; + result: IBarBarEqualQueryResult; }; - - - export type QuestionQuestionEqualQueryParams = []; - export interface IQuestionQuestionEqualQueryResult { - id: number; + id: number; }; - export interface IQuestionQuestionEqualQueryQuery { - params: QuestionQuestionEqualQueryParams; - result: IQuestionQuestionEqualQueryResult; + params: QuestionQuestionEqualQueryParams; + result: IQuestionQuestionEqualQueryResult; }; - - - export type CaretEqualQueryParams = []; - export interface ICaretEqualQueryResult { - id: number; + id: number; }; - export interface ICaretEqualQueryQuery { - params: CaretEqualQueryParams; - result: ICaretEqualQueryResult; + params: CaretEqualQueryParams; + result: ICaretEqualQueryResult; }; - diff --git a/tests/demo/typescript/expression/await.queries.ts b/tests/demo/typescript/expression/await.queries.ts index 784b65f9..b1339f58 100644 --- a/tests/demo/typescript/expression/await.queries.ts +++ b/tests/demo/typescript/expression/await.queries.ts @@ -1,47 +1,32 @@ - - export type AsyncPlainFunctionParams = []; - export interface IAsyncPlainFunctionResult { - id: number; + id: number; }; - export interface IAsyncPlainFunctionQuery { - params: AsyncPlainFunctionParams; - result: IAsyncPlainFunctionResult; + params: AsyncPlainFunctionParams; + result: IAsyncPlainFunctionResult; }; - - - export type AsyncLambdaAwaitedParams = []; - export interface IAsyncLambdaAwaitedResult { - id: number; + id: number; }; - export interface IAsyncLambdaAwaitedQuery { - params: AsyncLambdaAwaitedParams; - result: IAsyncLambdaAwaitedResult; + params: AsyncLambdaAwaitedParams; + result: IAsyncLambdaAwaitedResult; }; - - - export type IifLambdaParams = []; - export interface IIifLambdaResult { - id: number; + id: number; }; - export interface IIifLambdaQuery { - params: IifLambdaParams; - result: IIifLambdaResult; + params: IifLambdaParams; + result: IIifLambdaResult; }; - diff --git a/tests/demo/typescript/expression/await.snapshot.ts b/tests/demo/typescript/expression/await.snapshot.ts index 0bda37a7..4acaad5a 100644 --- a/tests/demo/typescript/expression/await.snapshot.ts +++ b/tests/demo/typescript/expression/await.snapshot.ts @@ -1,48 +1,33 @@ - - export type AsyncPlainFunctionParams = []; - export interface IAsyncPlainFunctionResult { - id: number; + id: number; }; - export interface IAsyncPlainFunctionQuery { - params: AsyncPlainFunctionParams; - result: IAsyncPlainFunctionResult; + params: AsyncPlainFunctionParams; + result: IAsyncPlainFunctionResult; }; - - - export type AsyncLambdaAwaitedParams = []; - export interface IAsyncLambdaAwaitedResult { - id: number; + id: number; }; - export interface IAsyncLambdaAwaitedQuery { - params: AsyncLambdaAwaitedParams; - result: IAsyncLambdaAwaitedResult; + params: AsyncLambdaAwaitedParams; + result: IAsyncLambdaAwaitedResult; }; - - - export type IifLambdaParams = []; - export interface IIifLambdaResult { - id: number; + id: number; }; - export interface IIifLambdaQuery { - params: IifLambdaParams; - result: IIifLambdaResult; + params: IifLambdaParams; + result: IIifLambdaResult; }; - diff --git a/tests/demo/typescript/expression/binary-operations.queries.ts b/tests/demo/typescript/expression/binary-operations.queries.ts index 3af93bd8..6fa29660 100644 --- a/tests/demo/typescript/expression/binary-operations.queries.ts +++ b/tests/demo/typescript/expression/binary-operations.queries.ts @@ -1,175 +1,120 @@ - - export type NullishCoalescingParams = []; - export interface INullishCoalescingResult { - id: number; + id: number; }; - export interface INullishCoalescingQuery { - params: NullishCoalescingParams; - result: INullishCoalescingResult; + params: NullishCoalescingParams; + result: INullishCoalescingResult; }; - - - export type PipePipeParams = []; - export interface IPipePipeResult { - id: number; + id: number; }; - export interface IPipePipeQuery { - params: PipePipeParams; - result: IPipePipeResult; + params: PipePipeParams; + result: IPipePipeResult; }; - - - export type AmpersandAmpersandParams = []; - export interface IAmpersandAmpersandResult { - id: number; + id: number; }; - export interface IAmpersandAmpersandQuery { - params: AmpersandAmpersandParams; - result: IAmpersandAmpersandResult; + params: AmpersandAmpersandParams; + result: IAmpersandAmpersandResult; }; - - - export type LessParams = []; - export interface ILessResult { - id: number; + id: number; }; - export interface ILessQuery { - params: LessParams; - result: ILessResult; + params: LessParams; + result: ILessResult; }; - - - export type LessThanParams = []; - export interface ILessThanResult { - id: number; + id: number; }; - export interface ILessThanQuery { - params: LessThanParams; - result: ILessThanResult; + params: LessThanParams; + result: ILessThanResult; }; - - - export type GreaterThanParams = []; - export interface IGreaterThanResult { - id: number; + id: number; }; - export interface IGreaterThanQuery { - params: GreaterThanParams; - result: IGreaterThanResult; + params: GreaterThanParams; + result: IGreaterThanResult; }; - - - export type GreaterEqualParams = []; - export interface IGreaterEqualResult { - id: number; + id: number; }; - export interface IGreaterEqualQuery { - params: GreaterEqualParams; - result: IGreaterEqualResult; + params: GreaterEqualParams; + result: IGreaterEqualResult; }; - - - export type EqualEqualParams = []; - export interface IEqualEqualResult { - id: number; + id: number; }; - export interface IEqualEqualQuery { - params: EqualEqualParams; - result: IEqualEqualResult; + params: EqualEqualParams; + result: IEqualEqualResult; }; - - - export type EqualEqualEqualParams = []; - export interface IEqualEqualEqualResult { - id: number; + id: number; }; - export interface IEqualEqualEqualQuery { - params: EqualEqualEqualParams; - result: IEqualEqualEqualResult; + params: EqualEqualEqualParams; + result: IEqualEqualEqualResult; }; - - - export type NotEqualEqualParams = []; - export interface INotEqualEqualResult { - id: number; + id: number; }; - export interface INotEqualEqualQuery { - params: NotEqualEqualParams; - result: INotEqualEqualResult; + params: NotEqualEqualParams; + result: INotEqualEqualResult; }; - - - export type NotEqualParams = []; - export interface INotEqualResult { - id: number; + id: number; }; - export interface INotEqualQuery { - params: NotEqualParams; - result: INotEqualResult; + params: NotEqualParams; + result: INotEqualResult; }; - diff --git a/tests/demo/typescript/expression/binary-operations.snapshot.ts b/tests/demo/typescript/expression/binary-operations.snapshot.ts index a4ee2125..8ae9e4e8 100644 --- a/tests/demo/typescript/expression/binary-operations.snapshot.ts +++ b/tests/demo/typescript/expression/binary-operations.snapshot.ts @@ -1,176 +1,121 @@ - - export type NullishCoalescingParams = []; - export interface INullishCoalescingResult { - id: number; + id: number; }; - export interface INullishCoalescingQuery { - params: NullishCoalescingParams; - result: INullishCoalescingResult; + params: NullishCoalescingParams; + result: INullishCoalescingResult; }; - - - export type PipePipeParams = []; - export interface IPipePipeResult { - id: number; + id: number; }; - export interface IPipePipeQuery { - params: PipePipeParams; - result: IPipePipeResult; + params: PipePipeParams; + result: IPipePipeResult; }; - - - export type AmpersandAmpersandParams = []; - export interface IAmpersandAmpersandResult { - id: number; + id: number; }; - export interface IAmpersandAmpersandQuery { - params: AmpersandAmpersandParams; - result: IAmpersandAmpersandResult; + params: AmpersandAmpersandParams; + result: IAmpersandAmpersandResult; }; - - - export type LessParams = []; - export interface ILessResult { - id: number; + id: number; }; - export interface ILessQuery { - params: LessParams; - result: ILessResult; + params: LessParams; + result: ILessResult; }; - - - export type LessThanParams = []; - export interface ILessThanResult { - id: number; + id: number; }; - export interface ILessThanQuery { - params: LessThanParams; - result: ILessThanResult; + params: LessThanParams; + result: ILessThanResult; }; - - - export type GreaterThanParams = []; - export interface IGreaterThanResult { - id: number; + id: number; }; - export interface IGreaterThanQuery { - params: GreaterThanParams; - result: IGreaterThanResult; + params: GreaterThanParams; + result: IGreaterThanResult; }; - - - export type GreaterEqualParams = []; - export interface IGreaterEqualResult { - id: number; + id: number; }; - export interface IGreaterEqualQuery { - params: GreaterEqualParams; - result: IGreaterEqualResult; + params: GreaterEqualParams; + result: IGreaterEqualResult; }; - - - export type EqualEqualParams = []; - export interface IEqualEqualResult { - id: number; + id: number; }; - export interface IEqualEqualQuery { - params: EqualEqualParams; - result: IEqualEqualResult; + params: EqualEqualParams; + result: IEqualEqualResult; }; - - - export type EqualEqualEqualParams = []; - export interface IEqualEqualEqualResult { - id: number; + id: number; }; - export interface IEqualEqualEqualQuery { - params: EqualEqualEqualParams; - result: IEqualEqualEqualResult; + params: EqualEqualEqualParams; + result: IEqualEqualEqualResult; }; - - - export type NotEqualEqualParams = []; - export interface INotEqualEqualResult { - id: number; + id: number; }; - export interface INotEqualEqualQuery { - params: NotEqualEqualParams; - result: INotEqualEqualResult; + params: NotEqualEqualParams; + result: INotEqualEqualResult; }; - - - export type NotEqualParams = []; - export interface INotEqualResult { - id: number; + id: number; }; - export interface INotEqualQuery { - params: NotEqualParams; - result: INotEqualResult; + params: NotEqualParams; + result: INotEqualResult; }; - diff --git a/tests/demo/typescript/expression/call.queries.ts b/tests/demo/typescript/expression/call.queries.ts index f109ab64..b3c89878 100644 --- a/tests/demo/typescript/expression/call.queries.ts +++ b/tests/demo/typescript/expression/call.queries.ts @@ -1,15 +1,10 @@ - - export type CallerTestParams = []; - export interface ICallerTestResult { - id: number; + id: number; }; - export interface ICallerTestQuery { - params: CallerTestParams; - result: ICallerTestResult; + params: CallerTestParams; + result: ICallerTestResult; }; - diff --git a/tests/demo/typescript/expression/call.snapshot.ts b/tests/demo/typescript/expression/call.snapshot.ts index 4cfd02df..1bd4451b 100644 --- a/tests/demo/typescript/expression/call.snapshot.ts +++ b/tests/demo/typescript/expression/call.snapshot.ts @@ -1,16 +1,11 @@ - - export type CallerTestParams = []; - export interface ICallerTestResult { - id: number; + id: number; }; - export interface ICallerTestQuery { - params: CallerTestParams; - result: ICallerTestResult; + params: CallerTestParams; + result: ICallerTestResult; }; - diff --git a/tests/demo/typescript/expression/chain.queries.ts b/tests/demo/typescript/expression/chain.queries.ts index 400ef835..933b18c6 100644 --- a/tests/demo/typescript/expression/chain.queries.ts +++ b/tests/demo/typescript/expression/chain.queries.ts @@ -1,31 +1,21 @@ - - export type ParentChildParams = []; - export interface IParentChildResult { - id: number; + id: number; }; - export interface IParentChildQuery { - params: ParentChildParams; - result: IParentChildResult; + params: ParentChildParams; + result: IParentChildResult; }; - - - export type OptionalParentChildParams = []; - export interface IOptionalParentChildResult { - id: number; + id: number; }; - export interface IOptionalParentChildQuery { - params: OptionalParentChildParams; - result: IOptionalParentChildResult; + params: OptionalParentChildParams; + result: IOptionalParentChildResult; }; - diff --git a/tests/demo/typescript/expression/chain.snapshot.ts b/tests/demo/typescript/expression/chain.snapshot.ts index f4e2aefc..15f8a9af 100644 --- a/tests/demo/typescript/expression/chain.snapshot.ts +++ b/tests/demo/typescript/expression/chain.snapshot.ts @@ -1,32 +1,22 @@ - - export type ParentChildParams = []; - export interface IParentChildResult { - id: number; + id: number; }; - export interface IParentChildQuery { - params: ParentChildParams; - result: IParentChildResult; + params: ParentChildParams; + result: IParentChildResult; }; - - - export type OptionalParentChildParams = []; - export interface IOptionalParentChildResult { - id: number; + id: number; }; - export interface IOptionalParentChildQuery { - params: OptionalParentChildParams; - result: IOptionalParentChildResult; + params: OptionalParentChildParams; + result: IOptionalParentChildResult; }; - diff --git a/tests/demo/typescript/expression/class-accessors.queries.ts b/tests/demo/typescript/expression/class-accessors.queries.ts index 001154cf..afbebf46 100644 --- a/tests/demo/typescript/expression/class-accessors.queries.ts +++ b/tests/demo/typescript/expression/class-accessors.queries.ts @@ -1,231 +1,163 @@ - - export type GetterQueryParams = []; - export interface IGetterQueryResult { - id: number; + id: number; }; - export interface IGetterQueryQuery { - params: GetterQueryParams; - result: IGetterQueryResult; + params: GetterQueryParams; + result: IGetterQueryResult; }; - - - export type SetterQueryParams = []; - export interface ISetterQueryResult { - id: number; + id: number; }; - export interface ISetterQueryQuery { - params: SetterQueryParams; - result: ISetterQueryResult; + params: SetterQueryParams; + result: ISetterQueryResult; }; - - - export type DefaultMethodQueryParams = []; - export interface IDefaultMethodQueryResult { - id: number; + id: number; }; - export interface IDefaultMethodQueryQuery { - params: DefaultMethodQueryParams; - result: IDefaultMethodQueryResult; + params: DefaultMethodQueryParams; + result: IDefaultMethodQueryResult; }; - - - export type PrivateMethodQueryParams = []; - export interface IPrivateMethodQueryResult { - id: number; + id: number; }; - export interface IPrivateMethodQueryQuery { - params: PrivateMethodQueryParams; - result: IPrivateMethodQueryResult; + params: PrivateMethodQueryParams; + result: IPrivateMethodQueryResult; }; - - - export type PublicMethodQueryParams = []; - export interface IPublicMethodQueryResult { - id: number; + id: number; }; - export interface IPublicMethodQueryQuery { - params: PublicMethodQueryParams; - result: IPublicMethodQueryResult; + params: PublicMethodQueryParams; + result: IPublicMethodQueryResult; }; - - - export type TestClassPropertyQueryParams = []; - export interface ITestClassPropertyQueryResult { - id: number; + id: number; }; - export interface ITestClassPropertyQueryQuery { - params: TestClassPropertyQueryParams; - result: ITestClassPropertyQueryResult; + params: TestClassPropertyQueryParams; + result: ITestClassPropertyQueryResult; }; - - - export type Sql2Params = []; - export interface ISql2Result { - id: number; + id: number; }; - export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; + params: Sql2Params; + result: ISql2Result; }; - - - export type TestClassConstructorQueryParams = []; - export interface ITestClassConstructorQueryResult { - id: number; + id: number; }; - export interface ITestClassConstructorQueryQuery { - params: TestClassConstructorQueryParams; - result: ITestClassConstructorQueryResult; + params: TestClassConstructorQueryParams; + result: ITestClassConstructorQueryResult; }; - - - export type SomeConstructorQueryParams = []; - export interface ISomeConstructorQueryResult { - id: number; + id: number; }; - export interface ISomeConstructorQueryQuery { - params: SomeConstructorQueryParams; - result: ISomeConstructorQueryResult; + params: SomeConstructorQueryParams; + result: ISomeConstructorQueryResult; }; - - - export type TestClassMethodQueryParams = []; - export interface ITestClassMethodQueryResult { - id: number; + id: number; }; - export interface ITestClassMethodQueryQuery { - params: TestClassMethodQueryParams; - result: ITestClassMethodQueryResult; + params: TestClassMethodQueryParams; + result: ITestClassMethodQueryResult; }; - - - export type SomeMethodQueryParams = []; - export interface ISomeMethodQueryResult { - id: number; + id: number; }; - export interface ISomeMethodQueryQuery { - params: SomeMethodQueryParams; - result: ISomeMethodQueryResult; + params: SomeMethodQueryParams; + result: ISomeMethodQueryResult; }; - - - export type TestChildClassConstructorQueryParams = []; - export interface ITestChildClassConstructorQueryResult { - id: number; + id: number; }; - export interface ITestChildClassConstructorQueryQuery { - params: TestChildClassConstructorQueryParams; - result: ITestChildClassConstructorQueryResult; + params: TestChildClassConstructorQueryParams; + result: ITestChildClassConstructorQueryResult; }; - - - export type PrivAutoAccessorPropParams = []; - export interface IPrivAutoAccessorPropResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IPrivAutoAccessorPropQuery { - params: PrivAutoAccessorPropParams; - result: IPrivAutoAccessorPropResult; + params: PrivAutoAccessorPropParams; + result: IPrivAutoAccessorPropResult; }; - - - export type AutoAccessorPropParams = []; - export interface IAutoAccessorPropResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IAutoAccessorPropQuery { - params: AutoAccessorPropParams; - result: IAutoAccessorPropResult; + params: AutoAccessorPropParams; + result: IAutoAccessorPropResult; }; - diff --git a/tests/demo/typescript/expression/class-accessors.snapshot.ts b/tests/demo/typescript/expression/class-accessors.snapshot.ts index 50f36c15..867ccea0 100644 --- a/tests/demo/typescript/expression/class-accessors.snapshot.ts +++ b/tests/demo/typescript/expression/class-accessors.snapshot.ts @@ -1,232 +1,164 @@ - - export type GetterQueryParams = []; - export interface IGetterQueryResult { - id: number; + id: number; }; - export interface IGetterQueryQuery { - params: GetterQueryParams; - result: IGetterQueryResult; + params: GetterQueryParams; + result: IGetterQueryResult; }; - - - export type SetterQueryParams = []; - export interface ISetterQueryResult { - id: number; + id: number; }; - export interface ISetterQueryQuery { - params: SetterQueryParams; - result: ISetterQueryResult; + params: SetterQueryParams; + result: ISetterQueryResult; }; - - - export type DefaultMethodQueryParams = []; - export interface IDefaultMethodQueryResult { - id: number; + id: number; }; - export interface IDefaultMethodQueryQuery { - params: DefaultMethodQueryParams; - result: IDefaultMethodQueryResult; + params: DefaultMethodQueryParams; + result: IDefaultMethodQueryResult; }; - - - export type PrivateMethodQueryParams = []; - export interface IPrivateMethodQueryResult { - id: number; + id: number; }; - export interface IPrivateMethodQueryQuery { - params: PrivateMethodQueryParams; - result: IPrivateMethodQueryResult; + params: PrivateMethodQueryParams; + result: IPrivateMethodQueryResult; }; - - - export type PublicMethodQueryParams = []; - export interface IPublicMethodQueryResult { - id: number; + id: number; }; - export interface IPublicMethodQueryQuery { - params: PublicMethodQueryParams; - result: IPublicMethodQueryResult; + params: PublicMethodQueryParams; + result: IPublicMethodQueryResult; }; - - - export type TestClassPropertyQueryParams = []; - export interface ITestClassPropertyQueryResult { - id: number; + id: number; }; - export interface ITestClassPropertyQueryQuery { - params: TestClassPropertyQueryParams; - result: ITestClassPropertyQueryResult; + params: TestClassPropertyQueryParams; + result: ITestClassPropertyQueryResult; }; - - - export type Sql2Params = []; - export interface ISql2Result { - id: number; + id: number; }; - export interface ISql2Query { - params: Sql2Params; - result: ISql2Result; + params: Sql2Params; + result: ISql2Result; }; - - - export type TestClassConstructorQueryParams = []; - export interface ITestClassConstructorQueryResult { - id: number; + id: number; }; - export interface ITestClassConstructorQueryQuery { - params: TestClassConstructorQueryParams; - result: ITestClassConstructorQueryResult; + params: TestClassConstructorQueryParams; + result: ITestClassConstructorQueryResult; }; - - - export type SomeConstructorQueryParams = []; - export interface ISomeConstructorQueryResult { - id: number; + id: number; }; - export interface ISomeConstructorQueryQuery { - params: SomeConstructorQueryParams; - result: ISomeConstructorQueryResult; + params: SomeConstructorQueryParams; + result: ISomeConstructorQueryResult; }; - - - export type TestClassMethodQueryParams = []; - export interface ITestClassMethodQueryResult { - id: number; + id: number; }; - export interface ITestClassMethodQueryQuery { - params: TestClassMethodQueryParams; - result: ITestClassMethodQueryResult; + params: TestClassMethodQueryParams; + result: ITestClassMethodQueryResult; }; - - - export type SomeMethodQueryParams = []; - export interface ISomeMethodQueryResult { - id: number; + id: number; }; - export interface ISomeMethodQueryQuery { - params: SomeMethodQueryParams; - result: ISomeMethodQueryResult; + params: SomeMethodQueryParams; + result: ISomeMethodQueryResult; }; - - - export type TestChildClassConstructorQueryParams = []; - export interface ITestChildClassConstructorQueryResult { - id: number; + id: number; }; - export interface ITestChildClassConstructorQueryQuery { - params: TestChildClassConstructorQueryParams; - result: ITestChildClassConstructorQueryResult; + params: TestChildClassConstructorQueryParams; + result: ITestChildClassConstructorQueryResult; }; - - - export type PrivAutoAccessorPropParams = []; - export interface IPrivAutoAccessorPropResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IPrivAutoAccessorPropQuery { - params: PrivAutoAccessorPropParams; - result: IPrivAutoAccessorPropResult; + params: PrivAutoAccessorPropParams; + result: IPrivAutoAccessorPropResult; }; - - - export type AutoAccessorPropParams = []; - export interface IAutoAccessorPropResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IAutoAccessorPropQuery { - params: AutoAccessorPropParams; - result: IAutoAccessorPropResult; + params: AutoAccessorPropParams; + result: IAutoAccessorPropResult; }; - diff --git a/tests/demo/typescript/expression/conditional.queries.ts b/tests/demo/typescript/expression/conditional.queries.ts index 949c307e..8435a48b 100644 --- a/tests/demo/typescript/expression/conditional.queries.ts +++ b/tests/demo/typescript/expression/conditional.queries.ts @@ -1,31 +1,21 @@ - - export type TruthyParams = []; - export interface ITruthyResult { - id: number; + id: number; }; - export interface ITruthyQuery { - params: TruthyParams; - result: ITruthyResult; + params: TruthyParams; + result: ITruthyResult; }; - - - export type FalsyParams = []; - export interface IFalsyResult { - id: number; + id: number; }; - export interface IFalsyQuery { - params: FalsyParams; - result: IFalsyResult; + params: FalsyParams; + result: IFalsyResult; }; - diff --git a/tests/demo/typescript/expression/conditional.snapshot.ts b/tests/demo/typescript/expression/conditional.snapshot.ts index 2836378a..95e596fc 100644 --- a/tests/demo/typescript/expression/conditional.snapshot.ts +++ b/tests/demo/typescript/expression/conditional.snapshot.ts @@ -1,32 +1,22 @@ - - export type TruthyParams = []; - export interface ITruthyResult { - id: number; + id: number; }; - export interface ITruthyQuery { - params: TruthyParams; - result: ITruthyResult; + params: TruthyParams; + result: ITruthyResult; }; - - - export type FalsyParams = []; - export interface IFalsyResult { - id: number; + id: number; }; - export interface IFalsyQuery { - params: FalsyParams; - result: IFalsyResult; + params: FalsyParams; + result: IFalsyResult; }; - diff --git a/tests/demo/typescript/expression/logical.queries.ts b/tests/demo/typescript/expression/logical.queries.ts index 3ed7ed17..28acfa01 100644 --- a/tests/demo/typescript/expression/logical.queries.ts +++ b/tests/demo/typescript/expression/logical.queries.ts @@ -1,47 +1,32 @@ - - export type NullishCoalescingParams = []; - export interface INullishCoalescingResult { - id: number; + id: number; }; - export interface INullishCoalescingQuery { - params: NullishCoalescingParams; - result: INullishCoalescingResult; + params: NullishCoalescingParams; + result: INullishCoalescingResult; }; - - - export type PipePipeParams = []; - export interface IPipePipeResult { - id: number; + id: number; }; - export interface IPipePipeQuery { - params: PipePipeParams; - result: IPipePipeResult; + params: PipePipeParams; + result: IPipePipeResult; }; - - - export type AmpersandAmpersandParams = []; - export interface IAmpersandAmpersandResult { - id: number; + id: number; }; - export interface IAmpersandAmpersandQuery { - params: AmpersandAmpersandParams; - result: IAmpersandAmpersandResult; + params: AmpersandAmpersandParams; + result: IAmpersandAmpersandResult; }; - diff --git a/tests/demo/typescript/expression/logical.snapshot.ts b/tests/demo/typescript/expression/logical.snapshot.ts index aafde29f..05320751 100644 --- a/tests/demo/typescript/expression/logical.snapshot.ts +++ b/tests/demo/typescript/expression/logical.snapshot.ts @@ -1,48 +1,33 @@ - - export type NullishCoalescingParams = []; - export interface INullishCoalescingResult { - id: number; + id: number; }; - export interface INullishCoalescingQuery { - params: NullishCoalescingParams; - result: INullishCoalescingResult; + params: NullishCoalescingParams; + result: INullishCoalescingResult; }; - - - export type PipePipeParams = []; - export interface IPipePipeResult { - id: number; + id: number; }; - export interface IPipePipeQuery { - params: PipePipeParams; - result: IPipePipeResult; + params: PipePipeParams; + result: IPipePipeResult; }; - - - export type AmpersandAmpersandParams = []; - export interface IAmpersandAmpersandResult { - id: number; + id: number; }; - export interface IAmpersandAmpersandQuery { - params: AmpersandAmpersandParams; - result: IAmpersandAmpersandResult; + params: AmpersandAmpersandParams; + result: IAmpersandAmpersandResult; }; - diff --git a/tests/demo/typescript/expression/new.queries.ts b/tests/demo/typescript/expression/new.queries.ts index 097f39cc..c41ce0b0 100644 --- a/tests/demo/typescript/expression/new.queries.ts +++ b/tests/demo/typescript/expression/new.queries.ts @@ -1,15 +1,10 @@ - - export type NewClassParams = []; - export interface INewClassResult { - id: number; + id: number; }; - export interface INewClassQuery { - params: NewClassParams; - result: INewClassResult; + params: NewClassParams; + result: INewClassResult; }; - diff --git a/tests/demo/typescript/expression/new.snapshot.ts b/tests/demo/typescript/expression/new.snapshot.ts index c37a1360..6adeb407 100644 --- a/tests/demo/typescript/expression/new.snapshot.ts +++ b/tests/demo/typescript/expression/new.snapshot.ts @@ -1,16 +1,11 @@ - - export type NewClassParams = []; - export interface INewClassResult { - id: number; + id: number; }; - export interface INewClassQuery { - params: NewClassParams; - result: INewClassResult; + params: NewClassParams; + result: INewClassResult; }; - diff --git a/tests/demo/typescript/expression/nullish-coalescing.queries.ts b/tests/demo/typescript/expression/nullish-coalescing.queries.ts index 853626d5..9f466553 100644 --- a/tests/demo/typescript/expression/nullish-coalescing.queries.ts +++ b/tests/demo/typescript/expression/nullish-coalescing.queries.ts @@ -1,19 +1,15 @@ - - export type TestNullishCoalescingQueryParams = []; - export interface ITestNullishCoalescingQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestNullishCoalescingQueryQuery { - params: TestNullishCoalescingQueryParams; - result: ITestNullishCoalescingQueryResult; + params: TestNullishCoalescingQueryParams; + result: ITestNullishCoalescingQueryResult; }; - diff --git a/tests/demo/typescript/expression/nullish-coalescing.snapshot.ts b/tests/demo/typescript/expression/nullish-coalescing.snapshot.ts index a036e699..8ece8679 100644 --- a/tests/demo/typescript/expression/nullish-coalescing.snapshot.ts +++ b/tests/demo/typescript/expression/nullish-coalescing.snapshot.ts @@ -1,20 +1,16 @@ - - export type TestNullishCoalescingQueryParams = []; - export interface ITestNullishCoalescingQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestNullishCoalescingQueryQuery { - params: TestNullishCoalescingQueryParams; - result: ITestNullishCoalescingQueryResult; + params: TestNullishCoalescingQueryParams; + result: ITestNullishCoalescingQueryResult; }; - diff --git a/tests/demo/typescript/expression/object.queries.ts b/tests/demo/typescript/expression/object.queries.ts index 88832586..0c2aef06 100644 --- a/tests/demo/typescript/expression/object.queries.ts +++ b/tests/demo/typescript/expression/object.queries.ts @@ -1,39 +1,31 @@ - - export type AnotherTestObjectQueryParams = []; - export interface IAnotherTestObjectQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IAnotherTestObjectQueryQuery { - params: AnotherTestObjectQueryParams; - result: IAnotherTestObjectQueryResult; + params: AnotherTestObjectQueryParams; + result: IAnotherTestObjectQueryResult; }; - - - export type NestedTestObjectQueryParams = []; - export interface INestedTestObjectQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface INestedTestObjectQueryQuery { - params: NestedTestObjectQueryParams; - result: INestedTestObjectQueryResult; + params: NestedTestObjectQueryParams; + result: INestedTestObjectQueryResult; }; - diff --git a/tests/demo/typescript/expression/object.snapshot.ts b/tests/demo/typescript/expression/object.snapshot.ts index 937af5da..cc92dbce 100644 --- a/tests/demo/typescript/expression/object.snapshot.ts +++ b/tests/demo/typescript/expression/object.snapshot.ts @@ -1,40 +1,32 @@ - - export type AnotherTestObjectQueryParams = []; - export interface IAnotherTestObjectQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface IAnotherTestObjectQueryQuery { - params: AnotherTestObjectQueryParams; - result: IAnotherTestObjectQueryResult; + params: AnotherTestObjectQueryParams; + result: IAnotherTestObjectQueryResult; }; - - - export type NestedTestObjectQueryParams = []; - export interface INestedTestObjectQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface INestedTestObjectQueryQuery { - params: NestedTestObjectQueryParams; - result: INestedTestObjectQueryResult; + params: NestedTestObjectQueryParams; + result: INestedTestObjectQueryResult; }; - diff --git a/tests/demo/typescript/expression/scope.queries.ts b/tests/demo/typescript/expression/scope.queries.ts index 26bb4fb9..4fe5c850 100644 --- a/tests/demo/typescript/expression/scope.queries.ts +++ b/tests/demo/typescript/expression/scope.queries.ts @@ -1,19 +1,15 @@ - - export type TestParenthesisQueryParams = []; - export interface ITestParenthesisQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestParenthesisQueryQuery { - params: TestParenthesisQueryParams; - result: ITestParenthesisQueryResult; + params: TestParenthesisQueryParams; + result: ITestParenthesisQueryResult; }; - diff --git a/tests/demo/typescript/expression/scope.snapshot.ts b/tests/demo/typescript/expression/scope.snapshot.ts index 256dc1ce..917c1b5a 100644 --- a/tests/demo/typescript/expression/scope.snapshot.ts +++ b/tests/demo/typescript/expression/scope.snapshot.ts @@ -1,20 +1,16 @@ - - export type TestParenthesisQueryParams = []; - export interface ITestParenthesisQueryResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestParenthesisQueryQuery { - params: TestParenthesisQueryParams; - result: ITestParenthesisQueryResult; + params: TestParenthesisQueryParams; + result: ITestParenthesisQueryResult; }; - diff --git a/tests/demo/typescript/expression/super.queries.ts b/tests/demo/typescript/expression/super.queries.ts index 09dcbb26..9d95d15b 100644 --- a/tests/demo/typescript/expression/super.queries.ts +++ b/tests/demo/typescript/expression/super.queries.ts @@ -1,15 +1,10 @@ - - export type SuperQueryParams = []; - export interface ISuperQueryResult { - id: number; + id: number; }; - export interface ISuperQueryQuery { - params: SuperQueryParams; - result: ISuperQueryResult; + params: SuperQueryParams; + result: ISuperQueryResult; }; - diff --git a/tests/demo/typescript/expression/super.snapshot.ts b/tests/demo/typescript/expression/super.snapshot.ts index 5e65c4f4..d9bb25d9 100644 --- a/tests/demo/typescript/expression/super.snapshot.ts +++ b/tests/demo/typescript/expression/super.snapshot.ts @@ -1,16 +1,11 @@ - - export type SuperQueryParams = []; - export interface ISuperQueryResult { - id: number; + id: number; }; - export interface ISuperQueryQuery { - params: SuperQueryParams; - result: ISuperQueryResult; + params: SuperQueryParams; + result: ISuperQueryResult; }; - diff --git a/tests/demo/typescript/expression/types.queries.ts b/tests/demo/typescript/expression/types.queries.ts index ceafc301..04294e92 100644 --- a/tests/demo/typescript/expression/types.queries.ts +++ b/tests/demo/typescript/expression/types.queries.ts @@ -1,15 +1,10 @@ - - export type ModuleSqlParams = []; - export interface IModuleSqlResult { - id: number; + id: number; }; - export interface IModuleSqlQuery { - params: ModuleSqlParams; - result: IModuleSqlResult; + params: ModuleSqlParams; + result: IModuleSqlResult; }; - diff --git a/tests/demo/typescript/expression/types.snapshot.ts b/tests/demo/typescript/expression/types.snapshot.ts index 944b6433..295c2ae6 100644 --- a/tests/demo/typescript/expression/types.snapshot.ts +++ b/tests/demo/typescript/expression/types.snapshot.ts @@ -1,16 +1,11 @@ - - export type ModuleSqlParams = []; - export interface IModuleSqlResult { - id: number; + id: number; }; - export interface IModuleSqlQuery { - params: ModuleSqlParams; - result: IModuleSqlResult; + params: ModuleSqlParams; + result: IModuleSqlResult; }; - diff --git a/tests/demo/typescript/expression/yield.queries.ts b/tests/demo/typescript/expression/yield.queries.ts index d6359618..1cefbe03 100644 --- a/tests/demo/typescript/expression/yield.queries.ts +++ b/tests/demo/typescript/expression/yield.queries.ts @@ -1,15 +1,10 @@ - - export type YieldQueryParams = []; - export interface IYieldQueryResult { - id: number; + id: number; }; - export interface IYieldQueryQuery { - params: YieldQueryParams; - result: IYieldQueryResult; + params: YieldQueryParams; + result: IYieldQueryResult; }; - diff --git a/tests/demo/typescript/expression/yield.snapshot.ts b/tests/demo/typescript/expression/yield.snapshot.ts index c6d71460..fcb77bc1 100644 --- a/tests/demo/typescript/expression/yield.snapshot.ts +++ b/tests/demo/typescript/expression/yield.snapshot.ts @@ -1,16 +1,11 @@ - - export type YieldQueryParams = []; - export interface IYieldQueryResult { - id: number; + id: number; }; - export interface IYieldQueryQuery { - params: YieldQueryParams; - result: IYieldQueryResult; + params: YieldQueryParams; + result: IYieldQueryResult; }; - diff --git a/tests/demo/typescript/statement/for.queries.ts b/tests/demo/typescript/statement/for.queries.ts index 92708d57..4bc83e3f 100644 --- a/tests/demo/typescript/statement/for.queries.ts +++ b/tests/demo/typescript/statement/for.queries.ts @@ -1,47 +1,32 @@ - - export type For1Params = []; - export interface IFor1Result { - id: number; + id: number; }; - export interface IFor1Query { - params: For1Params; - result: IFor1Result; + params: For1Params; + result: IFor1Result; }; - - - export type For2Params = []; - export interface IFor2Result { - id: number; + id: number; }; - export interface IFor2Query { - params: For2Params; - result: IFor2Result; + params: For2Params; + result: IFor2Result; }; - - - export type For3Params = []; - export interface IFor3Result { - id: number; + id: number; }; - export interface IFor3Query { - params: For3Params; - result: IFor3Result; + params: For3Params; + result: IFor3Result; }; - diff --git a/tests/demo/typescript/statement/for.snapshot.ts b/tests/demo/typescript/statement/for.snapshot.ts index df74efc5..e4feacd8 100644 --- a/tests/demo/typescript/statement/for.snapshot.ts +++ b/tests/demo/typescript/statement/for.snapshot.ts @@ -1,48 +1,33 @@ - - export type For1Params = []; - export interface IFor1Result { - id: number; + id: number; }; - export interface IFor1Query { - params: For1Params; - result: IFor1Result; + params: For1Params; + result: IFor1Result; }; - - - export type For2Params = []; - export interface IFor2Result { - id: number; + id: number; }; - export interface IFor2Query { - params: For2Params; - result: IFor2Result; + params: For2Params; + result: IFor2Result; }; - - - export type For3Params = []; - export interface IFor3Result { - id: number; + id: number; }; - export interface IFor3Query { - params: For3Params; - result: IFor3Result; + params: For3Params; + result: IFor3Result; }; - diff --git a/tests/demo/typescript/statement/function.queries.ts b/tests/demo/typescript/statement/function.queries.ts index d685aa59..1b707642 100644 --- a/tests/demo/typescript/statement/function.queries.ts +++ b/tests/demo/typescript/statement/function.queries.ts @@ -1,31 +1,21 @@ - - export type FunctionAssignParams = []; - export interface IFunctionAssignResult { - id: number; + id: number; }; - export interface IFunctionAssignQuery { - params: FunctionAssignParams; - result: IFunctionAssignResult; + params: FunctionAssignParams; + result: IFunctionAssignResult; }; - - - export type ReturnQueryParams = []; - export interface IReturnQueryResult { - id: number; + id: number; }; - export interface IReturnQueryQuery { - params: ReturnQueryParams; - result: IReturnQueryResult; + params: ReturnQueryParams; + result: IReturnQueryResult; }; - diff --git a/tests/demo/typescript/statement/function.snapshot.ts b/tests/demo/typescript/statement/function.snapshot.ts index ba5d73af..8611076e 100644 --- a/tests/demo/typescript/statement/function.snapshot.ts +++ b/tests/demo/typescript/statement/function.snapshot.ts @@ -1,32 +1,22 @@ - - export type FunctionAssignParams = []; - export interface IFunctionAssignResult { - id: number; + id: number; }; - export interface IFunctionAssignQuery { - params: FunctionAssignParams; - result: IFunctionAssignResult; + params: FunctionAssignParams; + result: IFunctionAssignResult; }; - - - export type ReturnQueryParams = []; - export interface IReturnQueryResult { - id: number; + id: number; }; - export interface IReturnQueryQuery { - params: ReturnQueryParams; - result: IReturnQueryResult; + params: ReturnQueryParams; + result: IReturnQueryResult; }; - diff --git a/tests/demo/typescript/statement/if.queries.ts b/tests/demo/typescript/statement/if.queries.ts index edb64d69..124990bc 100644 --- a/tests/demo/typescript/statement/if.queries.ts +++ b/tests/demo/typescript/statement/if.queries.ts @@ -1,31 +1,21 @@ - - export type IfstmtParams = []; - export interface IIfstmtResult { - id: number; + id: number; }; - export interface IIfstmtQuery { - params: IfstmtParams; - result: IIfstmtResult; + params: IfstmtParams; + result: IIfstmtResult; }; - - - export type NestedIfStmtParams = []; - export interface INestedIfStmtResult { - id: number; + id: number; }; - export interface INestedIfStmtQuery { - params: NestedIfStmtParams; - result: INestedIfStmtResult; + params: NestedIfStmtParams; + result: INestedIfStmtResult; }; - diff --git a/tests/demo/typescript/statement/if.snapshot.ts b/tests/demo/typescript/statement/if.snapshot.ts index 302e7645..0efacea6 100644 --- a/tests/demo/typescript/statement/if.snapshot.ts +++ b/tests/demo/typescript/statement/if.snapshot.ts @@ -1,32 +1,22 @@ - - export type IfstmtParams = []; - export interface IIfstmtResult { - id: number; + id: number; }; - export interface IIfstmtQuery { - params: IfstmtParams; - result: IIfstmtResult; + params: IfstmtParams; + result: IIfstmtResult; }; - - - export type NestedIfStmtParams = []; - export interface INestedIfStmtResult { - id: number; + id: number; }; - export interface INestedIfStmtQuery { - params: NestedIfStmtParams; - result: INestedIfStmtResult; + params: NestedIfStmtParams; + result: INestedIfStmtResult; }; - diff --git a/tests/demo/typescript/statement/switch.queries.ts b/tests/demo/typescript/statement/switch.queries.ts index bbbc1fc0..8221fd85 100644 --- a/tests/demo/typescript/statement/switch.queries.ts +++ b/tests/demo/typescript/statement/switch.queries.ts @@ -1,31 +1,21 @@ - - export type Case1Params = []; - export interface ICase1Result { - id: number; + id: number; }; - export interface ICase1Query { - params: Case1Params; - result: ICase1Result; + params: Case1Params; + result: ICase1Result; }; - - - export type Case2Params = []; - export interface ICase2Result { - id: number; + id: number; }; - export interface ICase2Query { - params: Case2Params; - result: ICase2Result; + params: Case2Params; + result: ICase2Result; }; - diff --git a/tests/demo/typescript/statement/switch.snapshot.ts b/tests/demo/typescript/statement/switch.snapshot.ts index c4c4cf12..6dbb97e0 100644 --- a/tests/demo/typescript/statement/switch.snapshot.ts +++ b/tests/demo/typescript/statement/switch.snapshot.ts @@ -1,32 +1,22 @@ - - export type Case1Params = []; - export interface ICase1Result { - id: number; + id: number; }; - export interface ICase1Query { - params: Case1Params; - result: ICase1Result; + params: Case1Params; + result: ICase1Result; }; - - - export type Case2Params = []; - export interface ICase2Result { - id: number; + id: number; }; - export interface ICase2Query { - params: Case2Params; - result: ICase2Result; + params: Case2Params; + result: ICase2Result; }; - diff --git a/tests/demo/typescript/statement/try.queries.ts b/tests/demo/typescript/statement/try.queries.ts index 3ea6088b..4b0b7555 100644 --- a/tests/demo/typescript/statement/try.queries.ts +++ b/tests/demo/typescript/statement/try.queries.ts @@ -1,15 +1,10 @@ - - export type Try2Params = []; - export interface ITry2Result { - someNumber: number; + someNumber: number; }; - export interface ITry2Query { - params: Try2Params; - result: ITry2Result; + params: Try2Params; + result: ITry2Result; }; - diff --git a/tests/demo/typescript/statement/try.snapshot.ts b/tests/demo/typescript/statement/try.snapshot.ts index ab34c110..31f1a241 100644 --- a/tests/demo/typescript/statement/try.snapshot.ts +++ b/tests/demo/typescript/statement/try.snapshot.ts @@ -1,16 +1,11 @@ - - export type Try2Params = []; - export interface ITry2Result { - someNumber: number; + someNumber: number; }; - export interface ITry2Query { - params: Try2Params; - result: ITry2Result; + params: Try2Params; + result: ITry2Result; }; - diff --git a/tests/demo/typescript/statement/using.queries.ts b/tests/demo/typescript/statement/using.queries.ts index 2639ba40..9d43c917 100644 --- a/tests/demo/typescript/statement/using.queries.ts +++ b/tests/demo/typescript/statement/using.queries.ts @@ -1,19 +1,15 @@ - - export type TestAsyncUsingParams = []; - export interface ITestAsyncUsingResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestAsyncUsingQuery { - params: TestAsyncUsingParams; - result: ITestAsyncUsingResult; + params: TestAsyncUsingParams; + result: ITestAsyncUsingResult; }; - diff --git a/tests/demo/typescript/statement/using.snapshot.ts b/tests/demo/typescript/statement/using.snapshot.ts index 84d8f133..dd9c9f21 100644 --- a/tests/demo/typescript/statement/using.snapshot.ts +++ b/tests/demo/typescript/statement/using.snapshot.ts @@ -1,20 +1,16 @@ - - export type TestAsyncUsingParams = []; - export interface ITestAsyncUsingResult { - food_type: string; + description: string | null; + food_type: string; id: number; points: number; table_id: number; time_takes_to_cook: number; }; - export interface ITestAsyncUsingQuery { - params: TestAsyncUsingParams; - result: ITestAsyncUsingResult; + params: TestAsyncUsingParams; + result: ITestAsyncUsingResult; }; - diff --git a/tests/demo/typescript/statement/while.queries.ts b/tests/demo/typescript/statement/while.queries.ts index 6021f8ed..d4879a45 100644 --- a/tests/demo/typescript/statement/while.queries.ts +++ b/tests/demo/typescript/statement/while.queries.ts @@ -1,31 +1,21 @@ - - export type WhileSqlParams = [boolean]; - export interface IWhileSqlResult { - id: number; + id: number; }; - export interface IWhileSqlQuery { - params: WhileSqlParams; - result: IWhileSqlResult; + params: WhileSqlParams; + result: IWhileSqlResult; }; - - - export type QueryParams = []; - export interface IQueryResult { - id: number; + id: number; }; - export interface IQueryQuery { - params: QueryParams; - result: IQueryResult; + params: QueryParams; + result: IQueryResult; }; - diff --git a/tests/demo/typescript/statement/while.snapshot.ts b/tests/demo/typescript/statement/while.snapshot.ts index 7f5078ee..6c385553 100644 --- a/tests/demo/typescript/statement/while.snapshot.ts +++ b/tests/demo/typescript/statement/while.snapshot.ts @@ -1,32 +1,22 @@ - - export type WhileSqlParams = [boolean]; - export interface IWhileSqlResult { - id: number; + id: number; }; - export interface IWhileSqlQuery { - params: WhileSqlParams; - result: IWhileSqlResult; + params: WhileSqlParams; + result: IWhileSqlResult; }; - - - export type QueryParams = []; - export interface IQueryResult { - id: number; + id: number; }; - export interface IQueryQuery { - params: QueryParams; - result: IQueryResult; + params: QueryParams; + result: IQueryResult; }; - diff --git a/tests/demo/typescript/weird.name.queries.ts b/tests/demo/typescript/weird.name.queries.ts index 1182d1ca..45d2f991 100644 --- a/tests/demo/typescript/weird.name.queries.ts +++ b/tests/demo/typescript/weird.name.queries.ts @@ -1,15 +1,10 @@ - - export type WeirdNameParams = []; - export interface IWeirdNameResult { - id: number; + id: number; }; - export interface IWeirdNameQuery { - params: WeirdNameParams; - result: IWeirdNameResult; + params: WeirdNameParams; + result: IWeirdNameResult; }; - diff --git a/tests/demo/typescript/weird.snapshot.ts b/tests/demo/typescript/weird.snapshot.ts index a5f72b8f..99cb06cf 100644 --- a/tests/demo/typescript/weird.snapshot.ts +++ b/tests/demo/typescript/weird.snapshot.ts @@ -1,16 +1,11 @@ - - export type WeirdNameParams = []; - export interface IWeirdNameResult { - id: number; + id: number; }; - export interface IWeirdNameQuery { - params: WeirdNameParams; - result: IWeirdNameResult; + params: WeirdNameParams; + result: IWeirdNameResult; }; - diff --git a/tests/demo/update/update.queries.ts b/tests/demo/update/update.queries.ts index 6ab67734..b8386adb 100644 --- a/tests/demo/update/update.queries.ts +++ b/tests/demo/update/update.queries.ts @@ -1,31 +1,32 @@ - - export type UpdateQueryParams = [string, number, number]; - export interface IUpdateQueryResult { - + }; - export interface IUpdateQueryQuery { - params: UpdateQueryParams; - result: IUpdateQueryResult; + params: UpdateQueryParams; + result: IUpdateQueryResult; }; - - - export type QuotedUpdateQueryParams = [string, number, number]; - export interface IQuotedUpdateQueryResult { - + }; - export interface IQuotedUpdateQueryQuery { - params: QuotedUpdateQueryParams; - result: IQuotedUpdateQueryResult; + params: QuotedUpdateQueryParams; + result: IQuotedUpdateQueryResult; +}; + +export type NullableFieldUpdateParams = [string | null, number]; + +export interface INullableFieldUpdateResult { + }; +export interface INullableFieldUpdateQuery { + params: NullableFieldUpdateParams; + result: INullableFieldUpdateResult; +}; diff --git a/tests/demo/update/update.snapshot.ts b/tests/demo/update/update.snapshot.ts index fbf3675f..d4ef85a6 100644 --- a/tests/demo/update/update.snapshot.ts +++ b/tests/demo/update/update.snapshot.ts @@ -1,32 +1,33 @@ - - export type UpdateQueryParams = [string, number, number]; - export interface IUpdateQueryResult { - + }; - export interface IUpdateQueryQuery { - params: UpdateQueryParams; - result: IUpdateQueryResult; + params: UpdateQueryParams; + result: IUpdateQueryResult; }; - - - export type QuotedUpdateQueryParams = [string, number, number]; - export interface IQuotedUpdateQueryResult { - + }; - export interface IQuotedUpdateQueryQuery { - params: QuotedUpdateQueryParams; - result: IQuotedUpdateQueryResult; + params: QuotedUpdateQueryParams; + result: IQuotedUpdateQueryResult; +}; + +export type NullableFieldUpdateParams = [string | null, number]; + +export interface INullableFieldUpdateResult { + }; +export interface INullableFieldUpdateQuery { + params: NullableFieldUpdateParams; + result: INullableFieldUpdateResult; +}; diff --git a/tests/demo/update/update.ts b/tests/demo/update/update.ts index a53004d2..39dc4635 100644 --- a/tests/demo/update/update.ts +++ b/tests/demo/update/update.ts @@ -11,3 +11,9 @@ UPDATE "items" SET "food_type" = $1, "time_takes_to_cook" = $2 WHERE "id" = $3 ` + +const nullableFieldUpdate = sql` +UPDATE "items" +SET description = $1 +WHERE "id" = $2 +` diff --git a/tests/enums.rs b/tests/enums.rs index dcb1a56c..08ca4d03 100644 --- a/tests/enums.rs +++ b/tests/enums.rs @@ -29,7 +29,7 @@ r#" export type UsersQueryParams = []; export interface IUsersQueryResult { - enum1: 'x-small' | 'small' | 'medium' | 'large' | 'x-large'; + enum1: 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | null; }; export interface IUsersQueryQuery { @@ -56,7 +56,7 @@ r#" export type UsersQueryParams = []; export interface IUsersQueryResult { - enum1: 'x-small' | 'small' | 'medium' | 'large' | 'x-large'; + enum1: 'x-small' | 'small' | 'medium' | 'large' | 'x-large' | null; }; export interface IUsersQueryQuery { diff --git a/tests/mysql_query_parameters.rs b/tests/mysql_query_parameters.rs index b2fd31c0..febe01f7 100644 --- a/tests/mysql_query_parameters.rs +++ b/tests/mysql_query_parameters.rs @@ -30,6 +30,7 @@ r#" export type SomeQueryParams = [number, number, number]; export interface ISomeQueryResult { + description: string | null; food_type: string; id: number; points: number; @@ -60,6 +61,7 @@ r#" export type SomeQueryParams = [Array]; export interface ISomeQueryResult { + description: string | null; food_type: string; id: number; points: number; @@ -99,6 +101,7 @@ r#" export type SomeQueryParams = [number, string, number]; export interface ISomeQueryResult { + description: string | null; food_type: string; id: number; points: number; @@ -138,6 +141,7 @@ r#" export type SomeQueryParams = [number, string, string]; export interface ISomeQueryResult { + description: string | null; food_type: string; id: number; points: number; diff --git a/tests/postgres_query_parameters.rs b/tests/postgres_query_parameters.rs index 47fe515e..3a134661 100644 --- a/tests/postgres_query_parameters.rs +++ b/tests/postgres_query_parameters.rs @@ -30,6 +30,7 @@ r#" export type SomeQueryParams = [number, number, number]; export interface ISomeQueryResult { + description: string | null; food_type: string; id: number; points: number; diff --git a/tests/sample/sample.queries.ts b/tests/sample/sample.queries.ts index f3b49a1e..70952b86 100644 --- a/tests/sample/sample.queries.ts +++ b/tests/sample/sample.queries.ts @@ -1,64 +1,44 @@ - - export type SampleSelectQueryParams = [number]; - export interface ISampleSelectQueryResult { - points: number; + points: number; some_id: number; }; - export interface ISampleSelectQueryQuery { - params: SampleSelectQueryParams; - result: ISampleSelectQueryResult; + params: SampleSelectQueryParams; + result: ISampleSelectQueryResult; }; - - - export type SampleInsertQueryParams = [number]; - export interface ISampleInsertQueryResult { - + }; - export interface ISampleInsertQueryQuery { - params: SampleInsertQueryParams; - result: ISampleInsertQueryResult; + params: SampleInsertQueryParams; + result: ISampleInsertQueryResult; }; - - - export type SampleUpdateQueryParams = [number, number]; - export interface ISampleUpdateQueryResult { - + }; - export interface ISampleUpdateQueryQuery { - params: SampleUpdateQueryParams; - result: ISampleUpdateQueryResult; + params: SampleUpdateQueryParams; + result: ISampleUpdateQueryResult; }; - - - export type SampleDeleteQueryParams = [number]; - export interface ISampleDeleteQueryResult { - + }; - export interface ISampleDeleteQueryQuery { - params: SampleDeleteQueryParams; - result: ISampleDeleteQueryResult; + params: SampleDeleteQueryParams; + result: ISampleDeleteQueryResult; }; -