Struct sqruff_lib::rules::convention::cv02::RuleCV02
source · pub struct RuleCV02;Expand description
Prefer using COALESCE over IFNULL or NVL.
§Anti-pattern
IFNULL or NVL are commonly used to handle NULL values in SQL queries.
However, they have compatibility issues across different database systems.
SELECT ifnull(foo, 0) AS bar,
FROM baz;
SELECT nvl(foo, 0) AS bar,
FROM baz;
§Best Practice
It is recommended to use COALESCE instead. COALESCE is universally
supported, while IFNULL is not supported in Redshift, and NVL is not
supported in BigQuery. Moreover, COALESCE offers greater flexibility, as
it can accept an arbitrary number of arguments, enhancing the query’s
robustness.
SELECT coalesce(foo, 0) AS bar,
FROM baz;
Trait Implementations§
source§impl Rule for RuleCV02
impl Rule for RuleCV02
fn load_from_config( &self, _config: &AHashMap<String, Value>, ) -> Result<ErasedRule, String>
fn name(&self) -> &'static str
fn description(&self) -> &'static str
fn long_description(&self) -> &'static str
source§fn groups(&self) -> &'static [RuleGroups]
fn groups(&self) -> &'static [RuleGroups]
All the groups this rule belongs to, including ‘all’ because that is a
given. There should be no duplicates and ‘all’ should be the first
element.
fn eval(&self, context: RuleContext<'_>) -> Vec<LintResult>
fn crawl_behaviour(&self) -> Crawler
fn lint_phase(&self) -> LintPhase
fn config_ref(&self) -> &'static str
fn force_enable(&self) -> bool
source§fn dialect_skip(&self) -> &'static [DialectKind]
fn dialect_skip(&self) -> &'static [DialectKind]
Returns the set of dialects for which a particular rule should be
skipped.
fn code(&self) -> &'static str
fn is_fix_compatible(&self) -> bool
fn crawl( &self, tables: &Tables, dialect: &Dialect, fix: bool, tree: ErasedSegment, config: &FluffConfig, ) -> (Vec<SQLLintError>, Vec<LintFix>)
fn process_lint_result( &self, res: LintResult, new_lerrs: &mut Vec<SQLLintError>, new_fixes: &mut Vec<LintFix>, )
Auto Trait Implementations§
impl Freeze for RuleCV02
impl RefUnwindSafe for RuleCV02
impl Send for RuleCV02
impl Sync for RuleCV02
impl Unpin for RuleCV02
impl UnwindSafe for RuleCV02
Blanket Implementations§
source§impl<T> AsAnyMut for Twhere
T: Any,
impl<T> AsAnyMut for Twhere
T: Any,
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more