Skip to content

Commit cce77ac

Browse files
committed
refactor: match the ROUND and current-time names where they are read
With main merged, the conversion constants file reached 2,005 lines, over the 2,000-line limit. The names sit in output_names.rs as match literals, as calls.rs writes them.
1 parent e8583f3 commit cce77ac

2 files changed

Lines changed: 6 additions & 8 deletions

File tree

‎crates/sqlquack-rules/src/conversion/_helpers/queries/output_names.rs‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::conversion::_helpers::support::tree::{
77
};
88
use crate::conversion::constants::{
99
OUTPUT_NAMED_AGGREGATES, OUTPUT_NAMED_ARITHMETIC, OUTPUT_NAMED_CAST_ENDINGS,
10-
OUTPUT_NAMED_CURRENT_TIME, OUTPUT_NAMED_FUNCTIONS, OUTPUT_NAMED_ROUND,
10+
OUTPUT_NAMED_FUNCTIONS,
1111
};
1212

1313
/// Whether an unaliased item written as `text` has a shape whose name receipts record.
@@ -38,9 +38,12 @@ pub(crate) fn recorded_name_shape(item: &Value, text: &str) -> bool {
3838
}
3939
"function" if arguments.is_empty() => {
4040
only(&["name", "args", "no_parens"])
41-
&& OUTPUT_NAMED_CURRENT_TIME.contains(&text.to_ascii_uppercase().as_str())
41+
&& matches!(
42+
text.to_ascii_uppercase().as_str(),
43+
"CURRENT_DATE()" | "CURRENT_DATE" | "CURRENT_TIMESTAMP()"
44+
)
4245
}
43-
"function" if named(&[OUTPUT_NAMED_ROUND]) => {
46+
"function" if named(&["ROUND"]) => {
4447
only(&["name", "args"])
4548
&& arguments.get(2).is_none()
4649
&& arguments.first().is_some_and(plain_column)

‎crates/sqlquack-rules/src/conversion/constants.rs‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,8 +1998,3 @@ pub(crate) const OUTPUT_NAMED_FUNCTIONS: &[&str] = &["LOWER", "UPPER", "COALESCE
19981998
pub(crate) const OUTPUT_NAMED_ARITHMETIC: &[&str] = &["add", "sub", "mul", "div"];
19991999
/// The cast target spellings whose unaliased column names receipts record.
20002000
pub(crate) const OUTPUT_NAMED_CAST_ENDINGS: &[&str] = &[" AS INTEGER)", "::INTEGER"];
2001-
/// ROUND, whose unaliased column names receipts record for a column and an integer scale.
2002-
pub(crate) const OUTPUT_NAMED_ROUND: &str = "ROUND";
2003-
/// The current-time items, as written upper-cased, whose unaliased column names receipts record.
2004-
pub(crate) const OUTPUT_NAMED_CURRENT_TIME: &[&str] =
2005-
&["CURRENT_DATE()", "CURRENT_DATE", "CURRENT_TIMESTAMP()"];

0 commit comments

Comments
 (0)